Popping the Bubble by Yamini Chandra

As an NYU student, I'll be the first to admit that I lived in a bubble, especially on social media regarding the 2016 election, I was really surprised by the results, and while all the articles I have read have provided context, I believe that the analysis below puts a different spin on things.

The goal of this is to deconstruct the 2016 election results by comparing it to the 2012 election. Using data from both elections, I plan to look at what changed from one election cycle to the next in swing states. The data was collected from kaggle and has been analyzed by multiple other sources before. I think looking at county data and looking at only swing states allows me to create an analysis that hasn't really been seen before.


In [3]:
import sys                             # system module
import pandas as pd                    # data package
from bqplot import Map, AlbersUSA, OrdinalColorScale, ColorAxis, Figure, topo_load
import requests

import matplotlib.pyplot as plt        # graphics module  
import datetime as dt                  # date and time module
import numpy as np                     # foundation for Pandas
import seaborn.apionly as sns          # fancy matplotlib graphics (no styling)
from pandas_datareader import wb, data as web  # worldbank data

# plotly imports
from plotly.offline import iplot, iplot_mpl  # plotting functions
import plotly.graph_objs as go               # ditto
import plotly                                # just to print version and init notebook
import cufflinks as cf                       # gives us df.iplot that feels like df.plot
cf.set_config_file(offline=True, offline_show_link=False)

# these lines make our graphics show up in the notebook
%matplotlib inline             
plotly.offline.init_notebook_mode(connected=True)

# check versions (overkill, but why not?)
print('Python version:', sys.version)
print('Pandas version: ', pd.__version__)
print('Plotly version: ', plotly.__version__)
print('Today: ', dt.date.today())


Python version: 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:52:12) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]
Pandas version:  0.19.0
Plotly version:  1.12.11
Today:  2016-12-22

Data Collection

data source

The data was easy to access, you only needed to sign up for an account in kaggle, but would not open properly when downloaded with safari. So I downloaded it on chrome and saved it to my desktop.


In [4]:
url = "https://www.kaggle.com/joelwilson/2012-2016-presidential-elections/downloads/votes.csv.zip"

r = requests.get(url) 

# describe response 
print('Response status code:', r.status_code)
print('Response type:', type(r))
print('Response .content:', type(r.content)) 
print('Response headers:\n', r.headers, sep='')


Response status code: 200
Response type: <class 'requests.models.Response'>
Response .content: <class 'bytes'>
Response headers:
{'Content-Encoding': 'gzip', 'X-Frame-Options': 'SAMEORIGIN, SAMEORIGIN', 'Content-Length': '5294', 'Content-Type': 'text/html; charset=utf-8', 'Vary': 'Accept-Encoding', 'Cache-Control': 'private', 'Date': 'Thu, 22 Dec 2016 21:44:09 GMT', 'Set-Cookie': 'AndNowBackToOurRegularlyScheduledProgramming=i5arxVN8KU4twc8pDSv4IYm5x1FaQjo2cyttdWzx02WjI4-GwHaQRrUI6sdta_KqFinrqQxJI4auvzP1HJTzcf9Q2KYu39G3cNZzLzbXgdTRUHiLC0tCUcYjyHAVtZ8t2eI0bjNjTazBe5QTwzTJ2pcIs9Y1; path=/, __RequestVerificationToken=RkUjCepM-53Uue68ZYxP0pN-dkQYR3NhVU3EVjSoFRATyoA18YE792LJcxo9t0wC38lzKNhgVRcPxkn6g1YdZDCU3Gk1; path=/; HttpOnly'}

In [353]:
location ="~/Desktop/votes-3.csv"
raw = pd.read_csv(location,index_col=0)

Cleaning the Data

So I first wanted to check what the raw file looked like, and its massive, 3000+ rows and 81 columns originally. Obviously this needs to be sized down. Unfortunately, there's a lot of codes in the column titles so the first goal is to make it comprehensible.


In [308]:
print(raw)


         X  combined_fips  votes_dem_2016  votes_gop_2016  total_votes_2016  \
30      29           1001            5908           18110             24661   
31      30           1003           18409           72780             94090   
32      31           1005            4848            5431             10390   
33      32           1007            1874            6733              8748   
34      33           1009            2150           22808             25384   
35      34           1011            3530            1139              4701   
36      35           1013            3716            4891              8685   
37      36           1015           13197           32803             47376   
38      37           1017            5763            7803             13778   
39      38           1019            1524            8809             10503   
40      39           1021            2909           15068             18255   
41      40           1023            3109            4102              7268   
42      41           1025            5712            7109             12936   
43      42           1027            1234            5230              6572   
44      43           1029             684            5738              6532   
45      44           1031            4194           15825             20513   
46      45           1033            7296           16718             24626   
47      46           1035            3069            3413              6543   
48      47           1037            1780            3376              5223   
49      48           1039            2379           13222             15818   
50      49           1041            1663            4511              6252   
51      50           1043            3730           32734             37278   
52      51           1045            4408           13798             18617   
53      52           1047           12826            5784             18730   
54      53           1049            3682           21779             26086   
55      54           1051            8436           27619             36905   
56      55           1053            4698           10282             15213   
57      56           1055           10350           32132             43474   
58      57           1057            1358            6705              8196   
59      58           1059            2197            9466             11955   
...    ...            ...             ...             ...               ...   
3112  3111          54097            1763            6971              9180   
3113  3112          54099            3334           11077             15080   
3114  3113          54101             554            2284              2955   
3115  3114          54103            1348            4461              6191   
3116  3115          54105             383            1903              2410   
3117  3116          54107            8327           25168             35256   
3118  3117          54109            1061            6527              7809   
3119  3118          56001            6888            7601             16420   
3120  3119          56003             594            4067              5079   
3121  3120          56005            1324           15778             17935   
3122  3121          56007            1279            4409              6200   
3123  3122          56009             668            5520              6552   
3124  3123          56011             271            3347              3771   
3125  3124          56013            4200           11167             16543   
3126  3125          56015             924            4418              5708   
3127  3126          56017             400            1939              2535   
3128  3127          56019             638            3477              4349   
3129  3128          56021           11572           24844             39945   
3130  3129          56023            1105            6779              8398   
3131  3130          56025            6573           23523             32493   
3132  3131          56027             115            1116              1297   
3133  3132          56029            2535           11115             14634   
3134  3133          56031             719            3437              4460   
3135  3134          56033            2926           10266             14187   
3136  3135          56035             644            3409              4297   
3137  3136          56037            3233           12153             16661   
3138  3137          56039            7313            3920             12176   
3139  3138          56041            1202            6154              8053   
3140  3139          56043             532            2911              3715   
3141  3140          56045             294            2898              3334   

       Clinton     Trump  diff_2016  per_point_diff_2016 state_abbr  \
30    0.239569  0.734358      12202            -0.494789         AL   
31    0.195653  0.773515      54371            -0.577862         AL   
32    0.466603  0.522714        583            -0.056112         AL   
33    0.214220  0.769662       4859            -0.555441         AL   
34    0.084699  0.898519      20658            -0.813820         AL   
35    0.750904  0.242289       2391             0.508615         AL   
36    0.427864  0.563155       1175            -0.135291         AL   
37    0.278559  0.692397      19606            -0.413838         AL   
38    0.418276  0.566338       2040            -0.148062         AL   
39    0.145101  0.838713       7285            -0.693611         AL   
40    0.159354  0.825418      12159            -0.666064         AL   
41    0.427766  0.564392        993            -0.136626         AL   
42    0.441558  0.549552       1397            -0.107993         AL   
43    0.187766  0.795800       3996            -0.608034         AL   
44    0.104715  0.878445       5054            -0.773729         AL   
45    0.204456  0.771462      11631            -0.567006         AL   
46    0.296272  0.678876       9422            -0.382604         AL   
47    0.469051  0.521626        344            -0.052575         AL   
48    0.340800  0.646372       1596            -0.305572         AL   
49    0.150398  0.835883      10843            -0.685485         AL   
50    0.265995  0.721529       2848            -0.455534         AL   
51    0.100059  0.878105      29004            -0.778046         AL   
52    0.236773  0.741151       9390            -0.504378         AL   
53    0.684784  0.308809       7042             0.375974         AL   
54    0.141149  0.834892      18097            -0.693744         AL   
55    0.228587  0.748381      19183            -0.519794         AL   
56    0.308815  0.675869       5584            -0.367054         AL   
57    0.238073  0.739108      21782            -0.501035         AL   
58    0.165691  0.818082       5347            -0.652391         AL   
59    0.183772  0.791803       7269            -0.608030         AL   
...        ...       ...        ...                  ...        ...   
3112  0.192048  0.759368       5208            -0.567320         WV   
3113  0.221088  0.734549       7743            -0.513462         WV   
3114  0.187479  0.772927       1730            -0.585448         WV   
3115  0.217735  0.720562       3113            -0.502827         WV   
3116  0.158921  0.789627       1520            -0.630705         WV   
3117  0.236187  0.713864      16841            -0.477678         WV   
3118  0.135869  0.835830       5466            -0.699962         WV   
3119  0.419488  0.462911        713            -0.043423         WY   
3120  0.116952  0.800748       3473            -0.683796         WY   
3121  0.073822  0.879732      14454            -0.805910         WY   
3122  0.206290  0.711129       3130            -0.504839         WY   
3123  0.101954  0.842491       4852            -0.740537         WY   
3124  0.071864  0.887563       3076            -0.815699         WY   
3125  0.253884  0.675029       6967            -0.421145         WY   
3126  0.161878  0.774001       3494            -0.612123         WY   
3127  0.157791  0.764892       1539            -0.607101         WY   
3128  0.146700  0.799494       2839            -0.652794         WY   
3129  0.289698  0.621955      13272            -0.332257         WY   
3130  0.131579  0.807216       5674            -0.675637         WY   
3131  0.202290  0.723941      16950            -0.521651         WY   
3132  0.088666  0.860447       1001            -0.771781         WY   
3133  0.173227  0.759533       8580            -0.586306         WY   
3134  0.161211  0.770628       2718            -0.609417         WY   
3135  0.206245  0.723620       7340            -0.517375         WY   
3136  0.149872  0.793344       2765            -0.643472         WY   
3137  0.194046  0.729428       8920            -0.535382         WY   
3138  0.600608  0.321945       3393             0.278663         WY   
3139  0.149261  0.764187       4952            -0.614926         WY   
3140  0.143203  0.783580       2379            -0.640377         WY   
3141  0.088182  0.869226       2604            -0.781044         WY   

            ...         AFN120207  BPS030214  LND110210  Density  \
30          ...             88157        131     594.44     91.8   
31          ...            436955       1384    1589.78    114.6   
32          ...                 0          8     884.88     31.0   
33          ...             10757         19     622.58     36.8   
34          ...             20941          3     644.78     88.9   
35          ...              3670          1     622.81     17.5   
36          ...             28427          2     776.83     27.0   
37          ...            186533        114     605.87    195.7   
38          ...             23237          8     596.53     57.4   
39          ...             13948          2     553.70     46.9   
40          ...             34073         78     692.85     63.0   
41          ...             11345          0     913.50     15.2   
42          ...             23596         11    1238.47     20.9   
43          ...              4352          0     603.96     23.1   
44          ...              4134          1     560.10     26.7   
45          ...             50080         58     678.97     73.6   
46          ...             61935        143     592.62     91.8   
47          ...              8667          3     850.16     15.6   
48          ...               575          0     650.93     17.7   
49          ...             30271          8    1030.46     36.6   
50          ...              5640          2     608.84     22.8   
51          ...            102291         77     734.84    109.4   
52          ...             37229         17     561.15     89.6   
53          ...             33708         17     978.70     44.8   
54          ...             67915         31     777.09     91.5   
55          ...             47884        259     618.49    128.2   
56          ...             31909         26     945.08     40.5   
57          ...            137966         79     534.99    195.2   
58          ...             10869          0     627.66     27.5   
59          ...             25389         13     633.82     50.0   
...         ...               ...        ...        ...      ...   
3112        ...             24548        100     354.64     68.4   
3113        ...             18397         16     505.98     84.0   
3114        ...              1965          0     553.47     16.5   
3115        ...             21022         20     358.06     46.3   
3116        ...               863         19     232.51     24.6   
3117        ...            157906        105     366.26    237.4   
3118        ...              9872          2     499.45     47.6   
3119        ...             65787         99    4273.84      8.5   
3120        ...              5611         13    3137.10      3.7   
3121        ...             89245        163    4802.71      9.6   
3122        ...             42949         31    7897.58      2.0   
3123        ...             20947         43    4254.88      3.3   
3124        ...              6135          5    2854.41      2.5   
3125        ...             66975         18    9183.81      4.4   
3126        ...             11779          1    2225.39      6.0   
3127        ...             10368          0    2004.09      2.4   
3128        ...             20749         12    4154.15      2.1   
3129        ...            173722        403    2685.91     34.2   
3130        ...             21115         68    4076.13      4.4   
3131        ...            167974        330    5340.35     14.1   
3132        ...              3071          1    2626.04      0.9   
3133        ...            132951        131    6942.08      4.1   
3134        ...             12103         22    2084.21      4.2   
3135        ...             66787        117    2523.99     11.5   
3136        ...             19746         27    4886.54      2.1   
3137        ...            150439        227   10426.65      4.2   
3138        ...            327363        145    3995.38      5.3   
3139        ...             35497         40    2081.26     10.1   
3140        ...             10175          4    2238.55      3.8   
3141        ...              7520          1    2398.09      3.0   

      Clinton_Obama  Trump_Romney  Trump_Prediction  Clinton_Prediction  \
30        -0.026189      0.008021          0.620859            0.340493   
31        -0.020013     -0.000383          0.586749            0.359502   
32        -0.045920      0.039339          0.517832            0.474693   
33        -0.047965      0.038998          0.692227            0.286031   
34        -0.038779      0.033590          0.789649            0.177490   
35        -0.012165      0.007238          0.445269            0.572216   
36        -0.032644      0.027354          0.522492            0.463313   
37        -0.056649      0.037726          0.633974            0.337479   
38        -0.052333      0.044706          0.585176            0.403332   
39        -0.072704      0.070964          0.761090            0.204391   
40        -0.035151      0.027551          0.728334            0.243327   
41        -0.047438      0.043362          0.589446            0.402700   
42        -0.015301      0.009811          0.528903            0.453499   
43        -0.078800      0.072608          0.747267            0.228325   
44        -0.049363      0.042361          0.817945            0.153821   
45        -0.044035      0.028982          0.580472            0.380051   
46        -0.095616      0.082872          0.644587            0.317199   
47        -0.037294      0.031964          0.524916            0.458974   
48        -0.076518      0.068840          0.655618            0.331308   
49        -0.054272      0.047820          0.709346            0.260562   
50        -0.053456      0.046751          0.669541            0.309933   
51        -0.046273      0.036282          0.756639            0.204065   
52        -0.048010      0.034720          0.611419            0.349515   
53        -0.012532      0.008657          0.350036            0.643058   
54        -0.078422      0.066668          0.783014            0.191398   
55        -0.023670      0.008454          0.597900            0.362290   
56        -0.060387      0.051341          0.599978            0.380954   
57        -0.062986      0.054194          0.668679            0.295626   
58        -0.062191      0.055443          0.744792            0.231844   
59        -0.108243      0.094961          0.750525            0.220175   
...             ...           ...               ...                 ...   
3112      -0.069453      0.042102          0.754293            0.201902   
3113      -0.131925      0.111623          0.806812            0.159302   
3114      -0.154722      0.150478          0.842515            0.134812   
3115      -0.160019      0.126726          0.798970            0.160443   
3116      -0.152221      0.132206          0.774558            0.176873   
3117      -0.093188      0.059698          0.706330            0.239036   
3118      -0.074243      0.068621          0.842727            0.131479   
3119      -0.044317     -0.026187          0.363671            0.551068   
3120      -0.048004     -0.010540          0.684907            0.258919   
3121      -0.049941      0.024208          0.701124            0.240335   
3122      -0.120130      0.068504          0.659909            0.278837   
3123      -0.071261      0.040359          0.697763            0.242477   
3124      -0.044625      0.037413          0.704171            0.236930   
3125      -0.063236      0.016647          0.579960            0.351380   
3126      -0.091335      0.048402          0.648272            0.290410   
3127      -0.051828      0.005773          0.733399            0.218125   
3128      -0.030914      0.002245          0.638343            0.295732   
3129      -0.073100      0.011108          0.593568            0.339556   
3130      -0.018544     -0.026098          0.698584            0.241677   
3131      -0.077212      0.033639          0.658126            0.280856   
3132      -0.069063      0.054453          0.685545            0.254448   
3133      -0.028747     -0.015654          0.632070            0.304426   
3134      -0.110567      0.073739          0.630632            0.302879   
3135      -0.048096      0.001863          0.631960            0.303194   
3136      -0.026978     -0.007209          0.652628            0.281005   
3137      -0.090909      0.047219          0.665093            0.272789   
3138       0.053672     -0.105847          0.425316            0.494972   
3139      -0.043333     -0.018139          0.685461            0.256831   
3140      -0.059814      0.013189          0.632028            0.305111   
3141      -0.038811      0.020294          0.717167            0.226544   

      Trump_Deviation  Clinton_Deviation  
30          -0.113499           0.100924  
31          -0.186766           0.163849  
32          -0.004882           0.008090  
33          -0.077434           0.071811  
34          -0.108870           0.092791  
35           0.202980          -0.178688  
36          -0.040663           0.035449  
37          -0.058423           0.058920  
38           0.018838          -0.014944  
39          -0.077623           0.059290  
40          -0.097084           0.083973  
41           0.025054          -0.025066  
42          -0.020648           0.011940  
43          -0.048534           0.040559  
44          -0.060499           0.049106  
45          -0.190990           0.175595  
46          -0.034289           0.020927  
47           0.003289          -0.010077  
48           0.009246          -0.009492  
49          -0.126537           0.110164  
50          -0.051989           0.043938  
51          -0.121466           0.104006  
52          -0.129732           0.112742  
53           0.041227          -0.041725  
54          -0.051878           0.050249  
55          -0.150481           0.133704  
56          -0.075891           0.072139  
57          -0.070429           0.057553  
58          -0.073290           0.066153  
59          -0.041277           0.036402  
...               ...                ...  
3112        -0.005075           0.009854  
3113         0.072263          -0.061785  
3114         0.069588          -0.052667  
3115         0.078408          -0.057292  
3116        -0.015068           0.017951  
3117        -0.007534           0.002849  
3118         0.006897          -0.004390  
3119        -0.099240           0.131580  
3120        -0.115841           0.141967  
3121        -0.178608           0.166513  
3122        -0.051220           0.072546  
3123        -0.144728           0.140523  
3124        -0.183392           0.165066  
3125        -0.095069           0.097496  
3126        -0.125730           0.128532  
3127        -0.031493           0.060334  
3128        -0.161151           0.149031  
3129        -0.028388           0.049858  
3130        -0.108632           0.110098  
3131        -0.065814           0.078567  
3132        -0.174902           0.165782  
3133        -0.127462           0.131199  
3134        -0.139996           0.141669  
3135        -0.091661           0.096949  
3136        -0.140717           0.131133  
3137        -0.064335           0.078743  
3138         0.103372          -0.105635  
3139        -0.078726           0.107570  
3140        -0.151552           0.161908  
3141        -0.152059           0.138361  

[3112 rows x 81 columns]

In [309]:
print(raw.shape)


(3112, 81)

In [310]:
print(list(raw.columns))


['X', 'combined_fips', 'votes_dem_2016', 'votes_gop_2016', 'total_votes_2016', 'Clinton', 'Trump', 'diff_2016', 'per_point_diff_2016', 'state_abbr', 'county_name', 'FIPS', 'total_votes_2012', 'votes_dem_2012', 'votes_gop_2012', 'county_fips', 'state_fips', 'Obama', 'Romney', 'diff_2012', 'per_point_diff_2012', 'fips', 'area_name', 'state_abbreviation', 'population2014', 'population2010', 'population_change', 'POP010210', 'AGE135214', 'AGE295214', 'age65plus', 'SEX255214', 'White', 'Black', 'RHI325214', 'RHI425214', 'RHI525214', 'RHI625214', 'Hispanic', 'RHI825214', 'POP715213', 'POP645213', 'NonEnglish', 'Edu_highschool', 'Edu_batchelors', 'VET605213', 'LFE305213', 'HSG010214', 'HSG445213', 'HSG096213', 'HSG495213', 'HSD410213', 'HSD310213', 'Income', 'INC110213', 'Poverty', 'BZA010213', 'BZA110213', 'BZA115213', 'NES010213', 'SBO001207', 'SBO315207', 'SBO115207', 'SBO215207', 'SBO515207', 'SBO415207', 'SBO015207', 'MAN450207', 'WTN220207', 'RTN130207', 'RTN131207', 'AFN120207', 'BPS030214', 'LND110210', 'Density', 'Clinton_Obama', 'Trump_Romney', 'Trump_Prediction', 'Clinton_Prediction', 'Trump_Deviation', 'Clinton_Deviation']

In [354]:
raw.columns = ['X', 'combined_fips', 'votes_dem_16', 'votes_gop_16', 'tot_votes_16',
               'Clinton', 'Trump', 'diff_216', 'per_point_diff_16', 'State', 'county',
               'FIPS', 'tot_votes_12', 'votes_dem_12', 'votes_gop_12', 'county_fips', 'state_fips', 
               'Obama', 'Romney', 'diff_12', 'per_point_diff_12', 'fips', 'County', 'state', 'pop2014est',
               'pop2010est', 'pop_change%', 'Pop2010', '-5', '-18', '65+', 'female', 'White', 'Black', 'Native', 
               'Asian', 'Pacific', 'Multi', 'Hispanic', 'White-nh', 'liveinhouse1yr', 'foreignborn', 'NonEnglish',
               'highschool', 'bachelors', 'Veterans', 'worktraveltime', 'Houseunits', 'Homeownrate', 'Houseunits%',
               'medvalhouse', 'tot_households', 'persperhouse', 'Percap_Inc', 'Med_house_inc', 'Poverty', 
               'nonfarmestab', 'nonfarmemp', 'nonfarm%', 'Nonempestab', 'TOT_firms', 'Black_own_firms', 
               'Nat_own_firms', 'Asian_own_firms', 'Pac_own_firms', 'Hisp_own_firms', 'Wom_own_firms', 
               'Manufact_ship', 'merch_whole', 'tot_ret_sales', 'Retsalepercap', 'Accomandfoodsales',
               'Buildingpermits', 'Landarea', 'Density', 'Clinton_Obama', 'Trump_Romney', 'Trump_Pred',
               'Clinton_Pred', 'Trump_Dev', 'Clinton_Dev']

In [312]:
print(list(raw.columns))


['X', 'combined_fips', 'votes_dem_16', 'votes_gop_16', 'tot_votes_16', 'Clinton', 'Trump', 'diff_216', 'per_point_diff_16', 'State', 'county', 'FIPS', 'tot_votes_12', 'votes_dem_12', 'votes_gop_12', 'county_fips', 'state_fips', 'Obama', 'Romney', 'diff_12', 'per_point_diff_12', 'fips', 'County', 'state', 'pop2014est', 'pop2010est', 'pop_change%', 'Pop2010', '-5', '-18', '65+', 'female', 'White', 'Black', 'Native', 'Asian', 'Pacific', 'Multi', 'Hispanic', 'White-nh', 'liveinhouse1yr', 'foreignborn', 'NonEnglish', 'highschool', 'bachelors', 'Veterans', 'worktraveltime', 'Houseunits', 'Homeownrate', 'Houseunits%', 'medvalhouse', 'tot_households', 'persperhouse', 'Percap_Inc', 'Med_house_inc', 'Poverty', 'nonfarmestab', 'nonfarmemp', 'nonfarm%', 'Nonempestab', 'TOT_firms', 'Black_own_firms', 'Nat_own_firms', 'Asian_own_firms', 'Pac_own_firms', 'Hisp_own_firms', 'Wom_own_firms', 'Manufact_ship', 'merch_whole', 'tot_ret_sales', 'Retsalepercap', 'Accomandfoodsales', 'Buildingpermits', 'Landarea', 'Density', 'Clinton_Obama', 'Trump_Romney', 'Trump_Pred', 'Clinton_Pred', 'Trump_Dev', 'Clinton_Dev']

Once the columns were understandable, I eliminated the columns that I knew for sure I wasn't going to use by deleting them from the data frame. I set the index to county because it's the main factor in the analysis.


In [361]:
#need to eliminate non-swing states
del raw ["state"]
del raw["county"]
del raw['X']
del raw['combined_fips']

del raw ['county_fips']
del raw ['state_fips']
del raw['fips']

The below document alows us to see which counties changed from one election cycle to another as well keep the data for which party held the county


In [362]:
raw["winner16"] = "GOP"
raw.loc[raw["Clinton"] > raw["Trump"], "winner16"] = "Dem"
raw["winner12"] = "GOP"
raw.loc[raw["Obama"] > raw["Romney"], "winner12"] = "Dem"
raw['change'] = "No Change"
raw.loc[raw["winner16"] != raw["winner12"], "change"] = raw["winner16"] + "change"
raw.loc[raw["winner16"] == raw["winner12"], "change"] = raw["winner12"]
raw.head()


Out[362]:
votes_dem_16 votes_gop_16 tot_votes_16 Clinton Trump diff_216 per_point_diff_16 State FIPS tot_votes_12 ... Density Clinton_Obama Trump_Romney Trump_Pred Clinton_Pred Trump_Dev Clinton_Dev winner16 winner12 change
30 5908 18110 24661 0.239569 0.734358 12202 -0.494789 AL 1001 23909 ... 91.8 -0.026189 0.008021 0.620859 0.340493 -0.113499 0.100924 GOP GOP GOP
31 18409 72780 94090 0.195653 0.773515 54371 -0.577862 AL 1003 84988 ... 114.6 -0.020013 -0.000383 0.586749 0.359502 -0.186766 0.163849 GOP GOP GOP
32 4848 5431 10390 0.466603 0.522714 583 -0.056112 AL 1005 11459 ... 31.0 -0.045920 0.039339 0.517832 0.474693 -0.004882 0.008090 GOP Dem GOPchange
33 1874 6733 8748 0.214220 0.769662 4859 -0.555441 AL 1007 8391 ... 36.8 -0.047965 0.038998 0.692227 0.286031 -0.077434 0.071811 GOP GOP GOP
34 2150 22808 25384 0.084699 0.898519 20658 -0.813820 AL 1009 23980 ... 88.9 -0.038779 0.033590 0.789649 0.177490 -0.108870 0.092791 GOP GOP GOP

5 rows × 77 columns

The next step was to seperate the swing states from the non-swing states. Initially, the plan was to use a function and create a seperate dataframe for each swing state and then merge them together. it created the right dataframes but didn't store them properly, as an alternative i just created the dataframes indepedently.


In [363]:
#drop non swing state rows 
def seperate(state):
    state = raw[raw.State == state]
    return state


swingstate = ['FL', 'CO', 'PA', 'NH', 'NV', 'NC','OH', 'WI', 'MI','IA', 'VA']
for item in swingstate:
    print(seperate(item))


     votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
321         75370         46584        127827  0.589625  0.364430     28786   
322          2112         10294         12634  0.167168  0.814785      8182   
323         21689         62010         87151  0.248867  0.711524     40321   
324          2924          8913         12098  0.241693  0.736733      5989   
325        119525        181620        314337  0.380245  0.577788     62095   
326        546956        258521        822837  0.664720  0.314183    288435   
327          1236          4647          6067  0.203725  0.765947      3411   
328         33421         60196         96323  0.346968  0.624939     26775   
329         22765         54377         79590  0.286028  0.683214     31612   
330         27768         74898        106363  0.261068  0.704173     47130   
331         60941        105297        170505  0.357415  0.617560     44356   
332          7599         20359         28696  0.264810  0.709472     12760   
333          3761          6744         10761  0.349503  0.626708      2983   
334          1270          5822          7202  0.176340  0.808387      4552   
335        203627        210061        428734  0.474950  0.489956      6434   
336         57114         88370        151609  0.376719  0.582881     31256   
337         21985         33804         57413  0.382927  0.588787     11819   
338          1738          4119          6003  0.289522  0.686157      2381   
339         14994          6721         22079  0.679107  0.304407      8273   
340          1457          6740          8418  0.173081  0.800665      5283   
341          1271          2996          4355  0.291848  0.687945      1725   
342          1715          5320          7279  0.235609  0.730870      3605   
343          1899          3439          5451  0.348376  0.630893      1540   
344          2147          5238          7577  0.283358  0.691303      3091   
345          4610          6192         11106  0.415091  0.557536      1582   
346         31818         59029         93878  0.338929  0.628784     27211   
347         14901         29509         45589  0.326855  0.647283     14608   
348        306422        265928        595072  0.514933  0.446884     40494   
349           852          7476          8506  0.100165  0.878909      6624   
350         28997         48564         79897  0.362930  0.607833     19567   
..            ...           ...           ...       ...       ...       ...   
358           651          2542          3295  0.197572  0.771472      1891   
359          3526          4849          8503  0.414677  0.570269      1323   
360         71066        101681        178521  0.398082  0.569574     30615   
361         61958        107710        174485  0.355091  0.617302     45752   
362         30158         53182         85741  0.351734  0.620263     23024   
363        623006        333666        978670  0.636584  0.340938    289340   
364         18949         21885         42434  0.446552  0.515742      2936   
365         10849         34221         46537  0.233126  0.735350     23372   
366         23711         71788        100657  0.235562  0.713194     48077   
367          3953          9342         13632  0.289979  0.685299      5389   
368        329579        195091        545800  0.603846  0.357440    134488   
369         85287         50252        139981  0.609276  0.358992     35035   
370        371411        270762        657235  0.565111  0.411971    100649   
371         89998        141943        240814  0.373724  0.589430     51945   
372        233327        238746        491520  0.474705  0.485730      5419   
373        117182        157216        283828  0.412863  0.553913     40034   
374          9920         21873         32652  0.303810  0.669882     11953   
375         18398         65126         87432  0.210426  0.744876     46728   
376         97676        124098        228509  0.427449  0.543077     26422   
377        105611        109265        224377  0.470685  0.486971      3654   
378         43037         88633        136392  0.315539  0.649840     45596   
379         66812         70248        140731  0.474750  0.499165      3436   
380         22631         52722         76649  0.295255  0.687837     30091   
381          3955         14281         18675  0.211780  0.764712     10326   
382          2149          6923          9279  0.231598  0.746093      4774   
383          1014          4567          5693  0.178113  0.802213      3553   
384        108793        142763        260304  0.417946  0.548447     33970   
385          4348         10507         15344  0.283368  0.684763      6159   
386          6861         25695         33559  0.204446  0.765666     18834   
387          2261          8630         11144  0.202889  0.774408      6369   

     per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
321           0.225195    FL  12001        120318    ...        282.7   
322          -0.647618    FL  12003         11366    ...         46.3   
323          -0.462657    FL  12005         79834    ...        222.6   
324          -0.495041    FL  12007         11631    ...         97.0   
325          -0.197543    FL  12009        285504    ...        535.0   
326           0.350537    FL  12011        755166    ...       1444.9   
327          -0.562222    FL  12013          6152    ...         25.8   
328          -0.277971    FL  12015         84664    ...        235.2   
329          -0.397186    FL  12017         73923    ...        242.8   
330          -0.443105    FL  12019         96549    ...        315.8   
331          -0.260145    FL  12021        149080    ...        160.9   
332          -0.444661    FL  12023         27163    ...         84.7   
333          -0.277205    FL  12027          9863    ...         54.7   
334          -0.632047    FL  12029          6941    ...         23.3   
335          -0.015007    FL  12031        411702    ...       1133.9   
336          -0.206162    FL  12033        148430    ...        453.4   
337          -0.205859    FL  12035         50589    ...        197.1   
338          -0.396635    FL  12037          5474    ...         21.6   
339           0.374700    FL  12039         22495    ...         89.8   
340          -0.627584    FL  12041          7908    ...         48.4   
341          -0.396096    FL  12043          3989    ...         16.0   
342          -0.495260    FL  12045          7107    ...         28.1   
343          -0.282517    FL  12047          5404    ...         28.8   
344          -0.407945    FL  12049          7222    ...         43.5   
345          -0.142446    FL  12051         10185    ...         34.0   
346          -0.289855    FL  12053         83593    ...        365.6   
347          -0.320428    FL  12055         42440    ...         97.2   
348           0.068049    FL  12057        541503    ...       1204.9   
349          -0.778744    FL  12059          8274    ...         41.6   
350          -0.244903    FL  12061         71445    ...        274.5   
..                 ...   ...    ...           ...    ...          ...   
358          -0.573900    FL  12077          3284    ...         10.0   
359          -0.155592    FL  12079          8712    ...         27.6   
360          -0.171492    FL  12081        153451    ...        434.5   
361          -0.262212    FL  12083        161368    ...        209.1   
362          -0.268530    FL  12085         78860    ...        269.2   
363           0.295646    FL  12086        877245    ...       1315.5   
364          -0.069190    FL  12087         39045    ...         74.3   
365          -0.502224    FL  12089         40523    ...        113.0   
366          -0.477632    FL  12091         94739    ...        194.4   
367          -0.395320    FL  12093         12321    ...         52.0   
368           0.246405    FL  12095        467385    ...       1268.5   
369           0.250284    FL  12097        108647    ...        202.4   
370           0.153140    FL  12099        600341    ...        670.2   
371          -0.215706    FL  12101        213358    ...        622.2   
372          -0.011025    FL  12103        457484    ...       3347.5   
373          -0.141050    FL  12105        248658    ...        334.9   
374          -0.366073    FL  12107         31323    ...        102.2   
375          -0.534450    FL  12113         76816    ...        149.6   
376          -0.115628    FL  12115        207434    ...        682.6   
377          -0.016285    FL  12117        208605    ...       1367.0   
378          -0.334301    FL  12109        114733    ...        316.4   
379          -0.024415    FL  12111        123026    ...        485.7   
380          -0.392582    FL  12119         60471    ...        170.8   
381          -0.552932    FL  12121         17627    ...         60.3   
382          -0.514495    FL  12123          9117    ...         21.6   
383          -0.624100    FL  12125          5393    ...         63.8   
384          -0.130501    FL  12127        234483    ...        449.2   
385          -0.401395    FL  12129         14656    ...         50.8   
386          -0.561221    FL  12131         28480    ...         53.0   
387          -0.571518    FL  12133         10998    ...         42.7   

     Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
321       0.010875     -0.040871    0.336634      0.598176  -0.027796   
322      -0.036070      0.025238    0.739175      0.230227  -0.075611   
323      -0.027168     -0.000742    0.618692      0.332602  -0.092832   
324      -0.044095      0.030345    0.729754      0.250544  -0.006979   
325      -0.050474      0.019932    0.561711      0.381513  -0.016077   
326      -0.007225     -0.008570    0.380616      0.568839   0.066434   
327      -0.066756      0.056259    0.742949      0.234175  -0.022998   
328      -0.077014      0.058134    0.653356      0.293517   0.028417   
329      -0.098872      0.079112    0.703400      0.246496   0.020186   
330      -0.005584     -0.020806    0.591457      0.354182  -0.112716   
331       0.010769     -0.029798    0.515859      0.425797  -0.101701   
332      -0.046716      0.031012    0.650074      0.313376  -0.059397   
333      -0.073695      0.060247    0.634327      0.333383   0.007619   
334      -0.082701      0.080538    0.779083      0.190969  -0.029304   
335      -0.002719     -0.023893    0.443787      0.512087  -0.046169   
336      -0.015075     -0.014512    0.513666      0.439253  -0.069215   
337      -0.075750      0.055746    0.569060      0.373380  -0.019727   
338      -0.047526      0.033983    0.681290      0.285827  -0.004867   
339      -0.021849      0.009764    0.428503      0.558729   0.124096   
340      -0.065285      0.052436    0.734723      0.225792  -0.065942   
341      -0.110007      0.100329    0.619661      0.340394  -0.068284   
342      -0.047633      0.028041    0.680260      0.291670  -0.050609   
343      -0.063541      0.050397    0.608693      0.374316  -0.022200   
344      -0.057407      0.041344    0.671735      0.302018  -0.019568   
345      -0.051379      0.031763    0.617464      0.356986   0.059928   
346      -0.113154      0.091586    0.679606      0.269411   0.050822   
347      -0.053611      0.036727    0.645144      0.311567  -0.002140   
348      -0.013519     -0.014617    0.439121      0.504773  -0.007762   
349      -0.052603      0.042675    0.749002      0.220809  -0.129907   
350      -0.021744     -0.000202    0.577255      0.369819  -0.030578   
..             ...           ...         ...           ...        ...   
358      -0.089273      0.070802    0.662117      0.312560  -0.109355   
359      -0.064432      0.056725    0.585183      0.397385   0.014914   
360      -0.035125      0.011637    0.558910      0.385717  -0.010665   
361      -0.059012      0.040757    0.620682      0.332800   0.003379   
362      -0.029917      0.009307    0.567061      0.374365  -0.053203   
363       0.020136     -0.038206    0.370879      0.574119   0.029941   
364      -0.050105      0.023131    0.540645      0.395698   0.024902   
365      -0.019792     -0.003144    0.647443      0.299080  -0.087908   
366      -0.011326     -0.027187    0.547919      0.392659  -0.165275   
367      -0.104144      0.090786    0.705457      0.270117   0.020158   
368       0.017120     -0.047059    0.391636      0.552239   0.034196   
369      -0.009251     -0.014521    0.494732      0.445901   0.135741   
370      -0.016921      0.000110    0.446815      0.499407   0.034843   
371      -0.086291      0.062921    0.634869      0.311420   0.045439   
372      -0.047643      0.019720    0.538597      0.408688   0.052867   
373      -0.048051      0.024809    0.587130      0.369309   0.033217   
374      -0.068632      0.052892    0.659715      0.307733  -0.010167   
375      -0.020736     -0.012375    0.608332      0.336101  -0.136544   
376      -0.030957      0.010431    0.564531      0.372905   0.021454   
377       0.008400     -0.040049    0.447489      0.488667  -0.039481   
378       0.009132     -0.034270    0.491764      0.442438  -0.158076   
379      -0.060657      0.042335    0.542528      0.411304   0.043363   
380      -0.027528      0.015713    0.628529      0.321323  -0.059307   
381      -0.057636      0.045815    0.690965      0.272806  -0.073747   
382      -0.071243      0.060670    0.701674      0.277400  -0.044419   
383      -0.070171      0.064220    0.702042      0.281766  -0.100171   
384      -0.071284      0.047460    0.594677      0.352470   0.046230   
385      -0.069593      0.051029    0.642822      0.311917  -0.041941   
386      -0.029578      0.011348    0.629359      0.321337  -0.136307   
387      -0.053521      0.043639    0.693702      0.273457  -0.080706   

    Clinton_Dev  winner16  winner12     change  
321    0.008551       Dem       Dem        Dem  
322    0.063059       GOP       GOP        GOP  
323    0.083735       GOP       GOP        GOP  
324    0.008851       GOP       GOP        GOP  
325    0.001268       GOP       GOP        GOP  
326   -0.095881       Dem       Dem        Dem  
327    0.030450       GOP       GOP        GOP  
328   -0.053451       GOP       GOP        GOP  
329   -0.039532       GOP       GOP        GOP  
330    0.093113       GOP       GOP        GOP  
331    0.068382       GOP       GOP        GOP  
332    0.048565       GOP       GOP        GOP  
333   -0.016120       GOP       GOP        GOP  
334    0.014629       GOP       GOP        GOP  
335    0.037138       GOP       GOP        GOP  
336    0.062534       GOP       GOP        GOP  
337   -0.009548       GOP       GOP        GOP  
338   -0.003695       GOP       GOP        GOP  
339   -0.120378       Dem       Dem        Dem  
340    0.052711       GOP       GOP        GOP  
341    0.048546       GOP       GOP        GOP  
342    0.056061       GOP       GOP        GOP  
343    0.025940       GOP       GOP        GOP  
344    0.018661       GOP       GOP        GOP  
345   -0.058105       GOP       GOP        GOP  
346   -0.069518       GOP       GOP        GOP  
347   -0.015289       GOP       GOP        GOP  
348   -0.010160       Dem       Dem        Dem  
349    0.120645       GOP       GOP        GOP  
350    0.006890       GOP       GOP        GOP  
..          ...       ...       ...        ...  
358    0.114988       GOP       GOP        GOP  
359   -0.017293       GOP       GOP        GOP  
360   -0.012365       GOP       GOP        GOP  
361   -0.022291       GOP       GOP        GOP  
362    0.022632       GOP       GOP        GOP  
363   -0.062465       Dem       Dem        Dem  
364   -0.050854       GOP       Dem  GOPchange  
365    0.065954       GOP       GOP        GOP  
366    0.157096       GOP       GOP        GOP  
367   -0.019862       GOP       GOP        GOP  
368   -0.051606       Dem       Dem        Dem  
369   -0.163375       Dem       Dem        Dem  
370   -0.065705       Dem       Dem        Dem  
371   -0.062304       GOP       GOP        GOP  
372   -0.066017       GOP       Dem  GOPchange  
373   -0.043554       GOP       GOP        GOP  
374    0.003923       GOP       GOP        GOP  
375    0.125675       GOP       GOP        GOP  
376   -0.054545       GOP       GOP        GOP  
377    0.017981       GOP       GOP        GOP  
378    0.126899       GOP       GOP        GOP  
379   -0.063446       GOP       Dem  GOPchange  
380    0.026068       GOP       GOP        GOP  
381    0.061026       GOP       GOP        GOP  
382    0.045802       GOP       GOP        GOP  
383    0.103653       GOP       GOP        GOP  
384   -0.065476       GOP       GOP        GOP  
385    0.028549       GOP       GOP        GOP  
386    0.116891       GOP       GOP        GOP  
387    0.070568       GOP       GOP        GOP  

[67 rows x 77 columns]
     votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
245         86471         73807        175125  0.493767  0.421453     12664   
246          3168          3031          6897  0.459330  0.439466       137   
247        148365        109638        281658  0.526756  0.389259     38727   
248          2489          4234          7290  0.341427  0.580796      1745   
249           278          1716          2107  0.131941  0.814428      1438   
250           581          1166          1892  0.307082  0.616279       585   
251        124715         38766        176735  0.705661  0.219345     85949   
252         19530         14272         37342  0.523004  0.382197      5258   
253          4773          5283         10999  0.433949  0.480316       510   
254           127           905          1076  0.118030  0.841078       778   
255          2585          2426          5532  0.467281  0.438539       159   
256          1753          1885          3970  0.441562  0.474811       132   
257          1109           581          1820  0.609341  0.319231       528   
258           336          1069          1511  0.222369  0.707478       733   
259           797          2059          3064  0.260117  0.671997      1262   
260          4048         11584         16661  0.242963  0.695276      7536   
261        174611         43637        232291  0.751691  0.187855    130974   
262           227           936          1230  0.184553  0.760976       709   
263         67045        100178        182918  0.366530  0.547666     33133   
264         12652          8153         22611  0.559551  0.360577      4499   
265          3056         11536         15689  0.194786  0.735292      8480   
266        105807        176506        313273  0.337747  0.563426     70699   
267          5275         15066         21880  0.241088  0.688574      9791   
268         11205         13071         26328  0.425593  0.496468      1866   
269          1634          1564          3574  0.457191  0.437605        70   
270          3319          4467          8513  0.389874  0.524727      1148   
271          5068          3250          9299  0.545005  0.349500      1818   
272           197           339           589  0.334465  0.575552       142   
273          1631          1875          3772  0.432397  0.497084       244   
274           171           628           862  0.198376  0.728538       457   
..            ...           ...           ...       ...       ...       ...   
279         15300         12471         30722  0.498014  0.405931      2829   
280         92170         82624        193897  0.475355  0.426123      9546   
281          2614          3656          6693  0.390557  0.546242      1042   
282           399          1873          2402  0.166112  0.779767      1474   
283          1843          7272          9702  0.189961  0.749536      5429   
284         20958         48129         74876  0.279903  0.642783     27171   
285           237           344           652  0.363497  0.527607       107   
286           874          5293          6510  0.134255  0.813057      4419   
287          3920          7771         12706  0.308516  0.611601      3851   
288          5438         14303         21070  0.258092  0.678832      8865   
289          3128          8104         11888  0.263122  0.681696      4976   
290          1719          2988          5038  0.341207  0.593092      1269   
291          1690          1337          3287  0.514147  0.406754       353   
292          3351          6053         10245  0.327086  0.590825      2702   
293           436          1791          2332  0.186964  0.768010      1355   
294          7239          2522         10387  0.696929  0.242804      4717   
295          1173          3508          4978  0.235637  0.704701      2335   
296         27945         27746         60112  0.464882  0.461572       199   
297           433          2782          3436  0.126019  0.809662      2349   
298          1985          3060          5488  0.361698  0.557580      1075   
299          7487          5149         13772  0.543639  0.373875      2338   
300          1345          1109          2707  0.496860  0.409679       236   
301           265           215           506  0.523715  0.424901        50   
302          2960          1030          4311  0.686616  0.238924      1930   
303           267          1015          1364  0.195748  0.744135       748   
304          9502          5064         16061  0.591619  0.315298      4438   
305          3547          9580         14203  0.249736  0.674505      6033   
306           289          2284          2708  0.106721  0.843427      1995   
307         45869         75882        133790  0.342843  0.567172     30013   
308           701          3755          4664  0.150300  0.805103      3054   

     per_point_diff_16 State  FIPS  tot_votes_12    ...      Density  \
245           0.072314    CO  8001        161495    ...        378.2   
246           0.019864    CO  8003          6671    ...         21.4   
247           0.137497    CO  8005        254746    ...        716.7   
248          -0.239369    CO  8007          6646    ...          8.9   
249          -0.682487    CO  8009          2096    ...          1.5   
250          -0.309197    CO  8011          1881    ...          4.3   
251           0.486316    CO  8013        173207    ...        405.6   
252           0.140807    CO  8014         32191    ...       1691.9   
253          -0.046368    CO  8015         10217    ...         17.6   
254          -0.723048    CO  8017          1045    ...          1.0   
255           0.028742    CO  8019          5610    ...         23.0   
256          -0.033249    CO  8021          4027    ...          6.4   
257           0.290110    CO  8023          1804    ...          2.9   
258          -0.485109    CO  8025          1502    ...          7.4   
259          -0.411880    CO  8027          2697    ...          5.8   
260          -0.452314    CO  8029         15681    ...         27.1   
261           0.563836    CO  8031        285564    ...       3922.6   
262          -0.576423    CO  8033          1218    ...          1.9   
263          -0.181136    CO  8035        150160    ...        339.7   
264           0.198974    CO  8037         22374    ...         31.0   
265          -0.540506    CO  8039         13993    ...         12.5   
266          -0.225679    CO  8041        275604    ...        292.6   
267          -0.447486    CO  8043         20258    ...         30.5   
268          -0.070875    CO  8045         23695    ...         19.1   
269           0.019586    CO  8047          3271    ...         36.3   
270          -0.134853    CO  8049          7961    ...          8.0   
271           0.195505    CO  8051          7912    ...          4.7   
272          -0.241087    CO  8053           598    ...          0.8   
273          -0.064687    CO  8055          3623    ...          4.2   
274          -0.530162    CO  8057           848    ...          0.9   
..                 ...   ...   ...           ...    ...          ...   
279           0.092084    CO  8067         28475    ...         30.3   
280           0.049232    CO  8069        161823    ...        115.4   
281          -0.155685    CO  8071          6532    ...          3.2   
282          -0.613655    CO  8073          2248    ...          2.1   
283          -0.559575    CO  8075          9030    ...         12.4   
284          -0.362880    CO  8077         69033    ...         44.1   
285          -0.164110    CO  8079           650    ...          0.8   
286          -0.678802    CO  8081          6042    ...          2.9   
287          -0.303085    CO  8083         12232    ...         12.6   
288          -0.420740    CO  8085         19054    ...         18.4   
289          -0.418573    CO  8087         10478    ...         22.0   
290          -0.251886    CO  8089          8039    ...         14.9   
291           0.107393    CO  8091          3183    ...          8.2   
292          -0.263738    CO  8093          9054    ...          7.4   
293          -0.581046    CO  8095          2265    ...          6.5   
294           0.454125    CO  8097          9779    ...         17.7   
295          -0.469064    CO  8099          4809    ...          7.7   
296           0.003310    CO  8101         73306    ...         66.7   
297          -0.683644    CO  8103          3311    ...          2.1   
298          -0.195882    CO  8105          5453    ...         13.1   
299           0.169765    CO  8107         13038    ...         10.0   
300           0.087181    CO  8109          2796    ...          1.9   
301           0.098814    CO  8111           506    ...          1.8   
302           0.447692    CO  8113          4215    ...          5.7   
303          -0.548387    CO  8115          1337    ...          4.3   
304           0.276322    CO  8117         15038    ...         46.0   
305          -0.424769    CO  8119         12144    ...         41.9   
306          -0.736706    CO  8121          2567    ...          1.9   
307          -0.224329    CO  8123        112695    ...         63.4   
308          -0.654803    CO  8125          4481    ...          4.2   

     Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
245      -0.068745      0.009484    0.574052      0.370770   0.152599   
246      -0.107601      0.035779    0.464092      0.462289   0.024625   
247      -0.004884     -0.059156    0.416054      0.517255   0.026795   
248      -0.055353      0.004359    0.544694      0.386303  -0.036102   
249      -0.088479      0.073016    0.691233      0.253411  -0.123195   
250      -0.106527      0.056470    0.669959      0.284330   0.053680   
251       0.010048     -0.060817    0.328393      0.590806   0.109048   
252       0.005685     -0.076472    0.425700      0.500042   0.043503   
253      -0.052202     -0.004072    0.579151      0.358418   0.098835   
254      -0.036994      0.020025    0.698733      0.249380  -0.142345   
255      -0.074786      0.014119    0.516598      0.408988   0.078059   
256      -0.099784      0.029318    0.537052      0.395965   0.062240   
257      -0.120704      0.075328    0.502670      0.436061   0.183439   
258      -0.133822      0.092299    0.612703      0.344370  -0.094776   
259      -0.059497      0.013488    0.562747      0.366554  -0.109250   
260      -0.046687      0.008968    0.669238      0.272288  -0.026038   
261       0.017148     -0.056416    0.337766      0.599705   0.149911   
262      -0.085562      0.072962    0.689799      0.252886  -0.071176   
263       0.006295     -0.077867    0.393975      0.527506  -0.153691   
264      -0.003514     -0.055844    0.421313      0.507545   0.060736   
265      -0.058340      0.010072    0.607049      0.323118  -0.128243   
266      -0.043195     -0.030974    0.467243      0.461722  -0.096183   
267      -0.086881      0.042558    0.685288      0.265098  -0.003286   
268      -0.038176     -0.016679    0.589548      0.351686   0.093081   
269      -0.109608      0.034059    0.592457      0.339704   0.154852   
270      -0.059190      0.003561    0.570024      0.359966   0.045297   
271      -0.031714     -0.043068    0.375822      0.545565   0.026322   
272      -0.046806     -0.013077    0.544594      0.389145  -0.030958   
273      -0.091203      0.051321    0.504582      0.428118   0.007499   
274      -0.056341      0.020991    0.680514      0.263162  -0.048024   
..             ...           ...         ...           ...        ...   
279      -0.030976     -0.034947    0.466367      0.457882   0.060436   
280      -0.038187     -0.034893    0.453955      0.469909   0.027832   
281      -0.111892      0.070890    0.587464      0.349052   0.041222   
282      -0.072767      0.039998    0.709086      0.249399  -0.070681   
283      -0.106274      0.071352    0.650353      0.290290  -0.099183   
284      -0.045275     -0.010340    0.605882      0.330818  -0.036901   
285      -0.084195     -0.001623    0.549049      0.379601   0.021442   
286      -0.079416      0.049071    0.701833      0.240073  -0.111223   
287      -0.058227      0.008919    0.536871      0.393152  -0.074730   
288      -0.049035      0.007635    0.610624      0.330506  -0.068209   
289      -0.095820      0.065071    0.670843      0.283360  -0.010852   
290      -0.102381      0.056334    0.572647      0.362355  -0.020446   
291      -0.001091     -0.055075    0.477273      0.445273   0.070519   
292      -0.083892      0.029195    0.580582      0.348984  -0.010243   
293      -0.072639      0.045273    0.656337      0.285473  -0.111673   
294       0.017105     -0.057943    0.380866      0.539538   0.138063   
295      -0.075862      0.039282    0.641134      0.305181  -0.063566   
296      -0.089288      0.038373    0.524722      0.404706   0.063151   
297      -0.043417      0.001145    0.625324      0.309946  -0.184339   
298      -0.083561      0.027230    0.556152      0.377858  -0.001428   
299      -0.023089     -0.037308    0.458668      0.464199   0.084794   
300      -0.133326      0.074557    0.552751      0.390837   0.143073   
301      -0.001976      0.005929    0.581218      0.344589   0.156317   
302      -0.015875     -0.032488    0.402430      0.518316   0.163507   
303      -0.117640      0.085197    0.683737      0.258359  -0.060398   
304      -0.018103     -0.050110    0.417380      0.502290   0.102082   
305      -0.070916      0.023237    0.603238      0.331607  -0.071267   
306      -0.072866      0.041323    0.688484      0.252019  -0.154943   
307      -0.077921      0.013909    0.573243      0.365401   0.006071   
308      -0.061706      0.038979    0.690967      0.252183  -0.114136   

    Clinton_Dev  winner16  winner12     change  
245   -0.122998       Dem       Dem        Dem  
246    0.002959       Dem       Dem        Dem  
247   -0.009501       Dem       Dem        Dem  
248    0.044876       GOP       GOP        GOP  
249    0.121470       GOP       GOP        GOP  
250   -0.022753       GOP       GOP        GOP  
251   -0.114855       Dem       Dem        Dem  
252   -0.022962       Dem       Dem        Dem  
253   -0.075530       GOP       Dem  GOPchange  
254    0.131351       GOP       GOP        GOP  
255   -0.058293       Dem       Dem        Dem  
256   -0.045597       GOP       Dem  GOPchange  
257   -0.173280       Dem       Dem        Dem  
258    0.122000       GOP       GOP        GOP  
259    0.106436       GOP       GOP        GOP  
260    0.029326       GOP       GOP        GOP  
261   -0.151985       Dem       Dem        Dem  
262    0.068333       GOP       GOP        GOP  
263    0.160975       GOP       GOP        GOP  
264   -0.052006       Dem       Dem        Dem  
265    0.128332       GOP       GOP        GOP  
266    0.123975       GOP       GOP        GOP  
267    0.024011       GOP       GOP        GOP  
268   -0.073906       GOP       GOP        GOP  
269   -0.117487       Dem       Dem        Dem  
270   -0.029909       GOP       GOP        GOP  
271    0.000560       Dem       Dem        Dem  
272    0.054680       GOP       GOP        GOP  
273   -0.004279       GOP       Dem  GOPchange  
274    0.064786       GOP       GOP        GOP  
..          ...       ...       ...        ...  
279   -0.040133       Dem       Dem        Dem  
280   -0.005447       Dem       Dem        Dem  
281   -0.041506       GOP       Dem  GOPchange  
282    0.083287       GOP       GOP        GOP  
283    0.100329       GOP       GOP        GOP  
284    0.050915       GOP       GOP        GOP  
285    0.016104       GOP       GOP        GOP  
286    0.105818       GOP       GOP        GOP  
287    0.084636       GOP       GOP        GOP  
288    0.072414       GOP       GOP        GOP  
289    0.020237       GOP       GOP        GOP  
290    0.021148       GOP       GOP        GOP  
291   -0.068874       Dem       Dem        Dem  
292    0.021897       GOP       GOP        GOP  
293    0.098509       GOP       GOP        GOP  
294   -0.157391       Dem       Dem        Dem  
295    0.069544       GOP       GOP        GOP  
296   -0.060177       Dem       Dem        Dem  
297    0.183927       GOP       GOP        GOP  
298    0.016160       GOP       GOP        GOP  
299   -0.079441       Dem       Dem        Dem  
300   -0.106023       Dem       Dem        Dem  
301   -0.179127       Dem       Dem        Dem  
302   -0.168300       Dem       Dem        Dem  
303    0.062611       GOP       GOP        GOP  
304   -0.089329       Dem       Dem        Dem  
305    0.081871       GOP       GOP        GOP  
306    0.145298       GOP       GOP        GOP  
307    0.022558       GOP       GOP        GOP  
308    0.101883       GOP       GOP        GOP  

[64 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
2244         14077         31249         47138  0.298634  0.662926     17172   
2245        363017        257488        643173  0.564416  0.400340    105529   
2246          6849         22676         30446  0.224956  0.744794     15827   
2247         30225         46081         79036  0.382421  0.583038     15856   
2248          3613         19455         23504  0.153719  0.827731     15842   
2249         75169         93094        175934  0.427257  0.529142     17925   
2250         13093         37224         52029  0.251648  0.715447     24131   
2251          6263         17957         25399  0.246585  0.706996     11694   
2252        165861        163873        342572  0.484164  0.478361      1988   
2253         26834         61388         92027  0.291588  0.667065     34554   
2254         17798         40510         60167  0.295810  0.673293     22712   
2255           469          1495          2024  0.231719  0.738636      1026   
2256          8917         18714         28721  0.310470  0.651579      9797   
2257         36555         35099         75394  0.484853  0.465541      1456   
2258        140188        115582        266637  0.525763  0.433481     24606   
2259          4256         12545         17481  0.243464  0.717636      8289   
2260          7700         23909         32692  0.235532  0.731341     16209   
2261          4533          9701         14839  0.305479  0.653750      5168   
2262          8502         17387         27127  0.313415  0.640948      8885   
2263         10215         23912         35563  0.287237  0.672384     13697   
2264         44282         65649        115068  0.384833  0.570524     21367   
2265         64287         60620        130160  0.493907  0.465734      3667   
2266        169169        106559        284832  0.593926  0.374112     62610   
2267          3637          9704         13854  0.262523  0.700448      6067   
2268         54820         57168        117240  0.467588  0.487615      2348   
2269         17826         34388         53426  0.333658  0.643657     16562   
2270           626          1680          2398  0.261051  0.700584      1054   
2271         17322         49554         69345  0.249795  0.714601     32232   
2272           904          5676          6743  0.134065  0.841762      4772   
2273          4157         10394         14955  0.277967  0.695018      6237   
...            ...           ...           ...       ...       ...       ...   
2281         17860         38804         58906  0.303195  0.658744     20944   
2282         77087         70285        153031  0.503735  0.459286      6802   
2283         51454         77508        132731  0.387656  0.583948     26054   
2284         12926         35475         50294  0.257009  0.705353     22549   
2285          3802         11159         15572  0.244156  0.716607      7357   
2286         17631         30034         49594  0.355507  0.605597     12403   
2287          3563         14050         18239  0.195351  0.770327     10487   
2288         31930         31706         65944  0.484199  0.480802       224   
2289        251063        160803        427489  0.587297  0.376157     90260   
2290          2851          5274          8535  0.334036  0.617926      2423   
2291         65936         71384        142775  0.461818  0.499975      5448   
2292          9184         24418         34971  0.262618  0.698236     15234   
2293          4630         15613         21153  0.218881  0.738099     10983   
2294        560542        105418        680227  0.824051  0.154975    455124   
2295          9247         16035         26066  0.354753  0.615169      6788   
2296          1300          6247          7777  0.167160  0.803266      4947   
2297         16724         43937         62750  0.266518  0.700191     27213   
2298          3991         11710         16333  0.244352  0.716953      7719   
2299          7367         27347         35730  0.206185  0.765379     19980   
2300           756          2318          3168  0.238636  0.731692      1562   
2301          5065         13295         19200  0.263802  0.692448      8230   
2302          3642         12928         17334  0.210107  0.745817      9286   
2303          6138         10605         17400  0.352759  0.609483      4467   
2304          5889         15254         22096  0.266519  0.690351      9365   
2305          4828         12032         17624  0.273945  0.682705      7204   
2306         34436         58941         96945  0.355212  0.607984     24505   
2307          6398         15269         22365  0.286072  0.682719      8871   
2308         59506        116427        181740  0.327424  0.640624     56921   
2309          3573          8375         12418  0.287727  0.674424      4802   
2310         67428        126933        203153  0.331907  0.624815     59505   

      per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
2244          -0.364292    PA  42001         41973    ...        195.5   
2245           0.164076    PA  42003        614671    ...       1675.6   
2246          -0.519838    PA  42005         28322    ...        105.5   
2247          -0.200617    PA  42007         80015    ...        392.3   
2248          -0.674013    PA  42009         21444    ...         49.2   
2249          -0.101885    PA  42011        163253    ...        480.4   
2250          -0.463799    PA  42013         47631    ...        241.7   
2251          -0.460412    PA  42015         22501    ...         54.6   
2252           0.005803    PA  42017        319407    ...       1034.7   
2253          -0.375477    PA  42019         88924    ...        233.1   
2254          -0.377483    PA  42021         57718    ...        208.7   
2255          -0.506917    PA  42023          1967    ...         12.8   
2256          -0.341109    PA  42025         24232    ...        171.1   
2257           0.019312    PA  42027         68801    ...        138.7   
2258           0.092283    PA  42029        248295    ...        664.7   
2259          -0.474172    PA  42031         15227    ...         66.6   
2260          -0.495809    PA  42033         31894    ...         71.3   
2261          -0.348271    PA  42035         12663    ...         44.2   
2262          -0.327533    PA  42037         24305    ...        139.3   
2263          -0.385147    PA  42039         33089    ...         87.7   
2264          -0.185690    PA  42041        109964    ...        431.6   
2265           0.028173    PA  42043        122625    ...        510.6   
2266           0.219814    PA  42045        272853    ...       3040.5   
2267          -0.437924    PA  42047         12425    ...         38.6   
2268          -0.020027    PA  42049        112732    ...        351.1   
2269          -0.309999    PA  42051         48196    ...        172.8   
2270          -0.439533    PA  42053          2308    ...         18.1   
2271          -0.464806    PA  42055         62802    ...        193.7   
2272          -0.707697    PA  42057          6148    ...         33.9   
2273          -0.417051    PA  42059         13726    ...         67.2   
...                 ...   ...    ...           ...    ...          ...   
2281          -0.355550    PA  42075         53771    ...        369.1   
2282           0.044449    PA  42077        144922    ...       1012.5   
2283          -0.196292    PA  42079        123741    ...        360.4   
2284          -0.448344    PA  42081         46214    ...         94.5   
2285          -0.472451    PA  42083         15014    ...         44.4   
2286          -0.250091    PA  42085         48065    ...        173.4   
2287          -0.574977    PA  42087         16311    ...        113.6   
2288           0.003397    PA  42089         59312    ...        279.2   
2289           0.211140    PA  42091        401787    ...       1655.9   
2290          -0.283890    PA  42093          7787    ...        140.3   
2291          -0.038158    PA  42095        125883    ...        805.4   
2292          -0.435618    PA  42097         31512    ...        206.2   
2293          -0.519217    PA  42099         18240    ...         83.4   
2294           0.669077    PA  42101        653598    ...      11379.5   
2295          -0.260416    PA  42103         23164    ...        105.3   
2296          -0.636106    PA  42105          7205    ...         16.1   
2297          -0.433673    PA  42107         57505    ...        190.4   
2298          -0.472601    PA  42109         14962    ...        120.8   
2299          -0.559194    PA  42111         33875    ...         72.4   
2300          -0.493056    PA  42113          2934    ...         14.3   
2301          -0.428646    PA  42115         17930    ...         52.7   
2302          -0.535710    PA  42117         15943    ...         37.0   
2303          -0.256724    PA  42119         16187    ...        142.2   
2304          -0.423832    PA  42121         20775    ...         81.5   
2305          -0.408761    PA  42123         16462    ...         47.3   
2306          -0.252772    PA  42125         90078    ...        242.5   
2307          -0.396647    PA  42127         20966    ...         72.8   
2308          -0.313200    PA  42129        168709    ...        355.4   
2309          -0.386697    PA  42131         11214    ...         71.2   
2310          -0.292907    PA  42133        186394    ...        481.1   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
2244      -0.056190      0.031806    0.717245      0.235391   0.054319   
2245      -0.001986     -0.021518    0.480831      0.460025   0.080491   
2246      -0.082014      0.065781    0.756381      0.191923   0.011587   
2247      -0.077906      0.056662    0.656516      0.288697   0.073478   
2248      -0.066856      0.057866    0.791460      0.164320  -0.036271   
2249      -0.062137      0.033855    0.615191      0.334654   0.086049   
2250      -0.074106      0.054113    0.701313      0.241631  -0.014135   
2251      -0.121888      0.092490    0.740910      0.208832   0.033914   
2252      -0.015506     -0.009656    0.553486      0.384176   0.075125   
2253      -0.027617     -0.001101    0.625355      0.313164  -0.041710   
2254      -0.105815      0.093508    0.699973      0.247239   0.026681   
2255      -0.112460      0.096033    0.772696      0.179913   0.034059   
2256      -0.145126      0.127066    0.747042      0.203832   0.095463   
2257      -0.004631     -0.024234    0.464211      0.464175  -0.001330   
2258       0.033478     -0.063025    0.435941      0.498246   0.002461   
2259      -0.067234      0.045935    0.705206      0.240708  -0.012431   
2260      -0.112277      0.094764    0.747762      0.203690   0.016421   
2261      -0.129094      0.105618    0.729900      0.221092   0.076150   
2262      -0.115468      0.087770    0.682169      0.263638   0.041220   
2263      -0.106368      0.083155    0.713353      0.236184   0.040969   
2264      -0.015143     -0.014804    0.588306      0.352889   0.017783   
2265      -0.029713      0.002224    0.506613      0.442497   0.040878   
2266      -0.010081     -0.011700    0.442098      0.506536   0.067986   
2267      -0.151481      0.129099    0.759772      0.186613   0.059324   
2268      -0.110207      0.078663    0.600408      0.342631   0.112793   
2269      -0.119513      0.107409    0.728816      0.224878   0.085159   
2270      -0.126297      0.102230    0.715891      0.253688   0.015307   
2271      -0.051311      0.028763    0.710944      0.243487  -0.003657   
2272      -0.076898      0.064273    0.802791      0.154870  -0.038971   
2273      -0.127395      0.113276    0.743434      0.211771   0.048416   
...             ...           ...         ...           ...        ...   
2281      -0.049690      0.026247    0.692677      0.258909   0.033932   
2282      -0.027786      0.003241    0.530111      0.413021   0.070825   
2283      -0.129343      0.115478    0.642919      0.301733   0.058971   
2284      -0.069819      0.045596    0.695955      0.253991  -0.009397   
2285      -0.106184      0.084264    0.718703      0.226717   0.002096   
2286      -0.124718      0.099949    0.677757      0.271269   0.072160   
2287      -0.065762      0.041187    0.803895      0.157605   0.033568   
2288      -0.079448      0.057616    0.551387      0.394649   0.070585   
2289       0.020925     -0.046711    0.433549      0.503022   0.057392   
2290      -0.054560      0.022575    0.655680      0.288751   0.037753   
2291      -0.054646      0.029364    0.597775      0.347301   0.097799   
2292      -0.130629      0.110650    0.754025      0.200454   0.055789   
2293      -0.078816      0.052189    0.770163      0.183311   0.032064   
2294      -0.028191      0.014460    0.292092      0.684066   0.137118   
2295      -0.084290      0.066343    0.635201      0.307166   0.020032   
2296      -0.095436      0.081684    0.749435      0.198051  -0.053831   
2297      -0.158715      0.141005    0.747176      0.206105   0.046984   
2298      -0.067906      0.045252    0.769208      0.190570   0.052254   
2299      -0.071896      0.058811    0.764589      0.191090  -0.000790   
2300      -0.111739      0.098086    0.747946      0.203628   0.016254   
2301      -0.120526      0.093731    0.739405      0.207529   0.046958   
2302      -0.106834      0.081012    0.710908      0.235272  -0.034909   
2303      -0.021801      0.000167    0.670585      0.285158   0.061102   
2304      -0.093000      0.068065    0.732508      0.213830   0.042157   
2305      -0.137184      0.110782    0.730264      0.215571   0.047559   
2306      -0.072229      0.047858    0.656054      0.288328   0.048070   
2307      -0.102080      0.085037    0.703791      0.245840   0.021072   
2308      -0.048253      0.027562    0.656756      0.284633   0.016132   
2309      -0.141379      0.122525    0.732015      0.214808   0.057591   
2310      -0.055047      0.026212    0.657834      0.291876   0.033019   

     Clinton_Dev  winner16  winner12     change  
2244   -0.063243       GOP       GOP        GOP  
2245   -0.104390       Dem       Dem        Dem  
2246   -0.033032       GOP       GOP        GOP  
2247   -0.093724       GOP       GOP        GOP  
2248    0.010601       GOP       GOP        GOP  
2249   -0.092603       GOP       GOP        GOP  
2250   -0.010018       GOP       GOP        GOP  
2251   -0.037753       GOP       GOP        GOP  
2252   -0.099988       Dem       Dem        Dem  
2253    0.021576       GOP       GOP        GOP  
2254   -0.048571       GOP       GOP        GOP  
2255   -0.051807       GOP       GOP        GOP  
2256   -0.106637       GOP       GOP        GOP  
2257   -0.020677       Dem       GOP  Demchange  
2258   -0.027517       Dem       GOP  Demchange  
2259   -0.002756       GOP       GOP        GOP  
2260   -0.031842       GOP       GOP        GOP  
2261   -0.084387       GOP       GOP        GOP  
2262   -0.049776       GOP       GOP        GOP  
2263   -0.051053       GOP       GOP        GOP  
2264   -0.031945       GOP       GOP        GOP  
2265   -0.051411       Dem       Dem        Dem  
2266   -0.087390       Dem       Dem        Dem  
2267   -0.075910       GOP       GOP        GOP  
2268   -0.124956       GOP       Dem  GOPchange  
2269   -0.108780       GOP       GOP        GOP  
2270   -0.007362       GOP       GOP        GOP  
2271   -0.006307       GOP       GOP        GOP  
2272    0.020805       GOP       GOP        GOP  
2273   -0.066196       GOP       GOP        GOP  
...          ...       ...       ...        ...  
2281   -0.044286       GOP       GOP        GOP  
2282   -0.090713       Dem       Dem        Dem  
2283   -0.085924       GOP       Dem  GOPchange  
2284   -0.003018       GOP       GOP        GOP  
2285   -0.017439       GOP       GOP        GOP  
2286   -0.084237       GOP       GOP        GOP  
2287   -0.037746       GOP       GOP        GOP  
2288   -0.089550       Dem       Dem        Dem  
2289   -0.084275       Dem       Dem        Dem  
2290   -0.045286       GOP       GOP        GOP  
2291   -0.114516       GOP       Dem  GOPchange  
2292   -0.062163       GOP       GOP        GOP  
2293   -0.035570       GOP       GOP        GOP  
2294   -0.139986       Dem       Dem        Dem  
2295   -0.047588       GOP       GOP        GOP  
2296    0.030891       GOP       GOP        GOP  
2297   -0.060413       GOP       GOP        GOP  
2298   -0.053782       GOP       GOP        GOP  
2299   -0.015095       GOP       GOP        GOP  
2300   -0.035008       GOP       GOP        GOP  
2301   -0.056273       GOP       GOP        GOP  
2302    0.025164       GOP       GOP        GOP  
2303   -0.067600       GOP       GOP        GOP  
2304   -0.052689       GOP       GOP        GOP  
2305   -0.058373       GOP       GOP        GOP  
2306   -0.066884       GOP       GOP        GOP  
2307   -0.040232       GOP       GOP        GOP  
2308   -0.042791       GOP       GOP        GOP  
2309   -0.072920       GOP       GOP        GOP  
2310   -0.040032       GOP       GOP        GOP  

[67 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
1900         13517         19315         34462  0.392229  0.560472      5798   
1901         12987         14635         29063  0.446857  0.503561      1648   
1902         22064         16876         41080  0.537098  0.410808      5188   
1903          6558          7951         15255  0.429892  0.521206      1393   
1904         28510         19010         50065  0.569460  0.379706      9500   
1905         99589        100013        210622  0.472833  0.474846       424   
1906         40198         37674         81982  0.490327  0.459540      2524   
1907         79994         90447        179005  0.446881  0.505276     10453   
1908         34894         29072         67918  0.513767  0.428046      5822   
1909         10210         10796         22101  0.461970  0.488485       586   

      per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
1900          -0.168243    NH  33001         33771    ...        150.1   
1901          -0.056704    NH  33003         28464    ...         51.4   
1902           0.126290    NH  33005         41071    ...        109.1   
1903          -0.091314    NH  33007         15614    ...         18.4   
1904           0.189753    NH  33009         48765    ...         52.2   
1905          -0.002013    NH  33011        202765    ...        457.4   
1906           0.030787    NH  33013         80054    ...        156.8   
1907          -0.058395    NH  33015        169794    ...        425.0   
1908           0.085721    NH  33017         63762    ...        333.7   
1909          -0.026515    NH  33019         21814    ...         81.4   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
1900      -0.078115      0.040263    0.652807      0.289498   0.092335   
1901      -0.044184      0.004440    0.626437      0.312406   0.122876   
1902      -0.079614      0.042300    0.622108      0.316917   0.211300   
1903      -0.152342      0.115032    0.745739      0.207149   0.224533   
1904      -0.042167      0.006344    0.555161      0.380755   0.175454   
1905      -0.027742     -0.008980    0.567800      0.371484   0.092954   
1906      -0.067234      0.029193    0.603683      0.334960   0.144143   
1907      -0.024843     -0.011874    0.575393      0.359123   0.070116   
1908      -0.051241      0.008062    0.601652      0.336694   0.173607   
1909      -0.095745      0.063574    0.675312      0.268606   0.186827   

     Clinton_Dev  winner16  winner12     change  
1900   -0.102731       GOP       GOP        GOP  
1901   -0.134451       GOP       GOP        GOP  
1902   -0.220182       Dem       Dem        Dem  
1903   -0.222743       GOP       Dem  GOPchange  
1904   -0.188704       Dem       Dem        Dem  
1905   -0.101349       GOP       Dem  GOPchange  
1906   -0.155367       Dem       Dem        Dem  
1907   -0.087758       GOP       GOP        GOP  
1908   -0.177072       Dem       Dem        Dem  
1909   -0.193365       GOP       Dem  GOPchange  

[10 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
1964          9610         13125         25016  0.384154  0.524664      3515   
1965          2210          7828         10936  0.202085  0.715801      5618   
1966        401068        319571        765421  0.523984  0.417510     81497   
1967          8453         17406         27871  0.303290  0.624520      8953   
1968          3400         13542         18545  0.183338  0.730224     10142   
1969            65           329           423  0.153664  0.777778       264   
1970            74           723           854  0.086651  0.846604       649   
1971          1386          4521          6433  0.215452  0.702783      3135   
1972           403          1828          2413  0.167012  0.757563      1425   
1973           285          1671          2132  0.133677  0.783771      1386   
1974          6146         16005         23762  0.258648  0.673554      9859   
1975           637          1179          1997  0.318978  0.590386       542   
1976          5095         13320         19592  0.260055  0.679869      8225   
1977           430          1403          1982  0.216953  0.707871       973   
1978           752          1616          2558  0.293980  0.631744       864   
1979         97032         94529        209282  0.463642  0.451682      2503   
1980           707          2723          3773  0.187384  0.721707      2016   

      per_point_diff_16 State   FIPS  tot_votes_12   ...    Density  \
1964          -0.140510    NV  32510         23318   ...      382.1   
1965          -0.513716    NV  32001         10265   ...        5.0   
1966           0.106473    NV  32003        688339   ...      247.3   
1967          -0.321230    NV  32005         26054   ...       66.2   
1968          -0.546886    NV  32007         15984   ...        2.8   
1969          -0.624113    NV  32009           435   ...        0.2   
1970          -0.759953    NV  32011           808   ...        0.5   
1971          -0.487331    NV  32013          5744   ...        1.7   
1972          -0.590551    NV  32015          2165   ...        1.1   
1973          -0.650094    NV  32017          2152   ...        0.5   
1974          -0.414906    NV  32019         21465   ...       26.0   
1975          -0.271407    NV  32021          2035   ...        1.3   
1976          -0.419814    NV  32023         17522   ...        2.4   
1977          -0.490918    NV  32027          1884   ...        1.1   
1978          -0.337764    NV  32029          2314   ...       15.3   
1979           0.011960    NV  32031        186917   ...       66.9   
1980          -0.534323    NV  32033          3704   ...        1.1   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
1964      -0.057136     -0.006856    0.608089      0.331909   0.083425   
1965      -0.086371      0.027930    0.639958      0.298412  -0.075843   
1966      -0.039660     -0.001212    0.507896      0.436609   0.090386   
1967      -0.053200      0.000278    0.607854      0.325570  -0.016666   
1968      -0.036257     -0.021340    0.680719      0.269041  -0.049505   
1969      -0.057830      0.049042    0.658724      0.286321  -0.119053   
1970      -0.045775      0.026060    0.611568      0.326234  -0.235036   
1971      -0.086951      0.039482    0.694702      0.254088  -0.008081   
1972      -0.079639      0.027771    0.730813      0.224031  -0.026750   
1973      -0.052196     -0.002010    0.707913      0.246836  -0.075858   
1974      -0.085167      0.043692    0.677678      0.269816   0.004124   
1975      -0.105100      0.059673    0.617173      0.320625   0.026788   
1976      -0.100634      0.076856    0.700656      0.249373   0.020786   
1977      -0.118504      0.088444    0.699857      0.256601  -0.008014   
1978      -0.103600      0.060871    0.641950      0.292058   0.010207   
1979      -0.043567     -0.019923    0.539831      0.396436   0.088149   
1980      -0.078005      0.019493    0.685127      0.263394  -0.036580   

     Clinton_Dev  winner16  winner12  change  
1964   -0.052245       GOP       GOP     GOP  
1965    0.096328       GOP       GOP     GOP  
1966   -0.087374       Dem       Dem     Dem  
1967    0.022280       GOP       GOP     GOP  
1968    0.085703       GOP       GOP     GOP  
1969    0.132657       GOP       GOP     GOP  
1970    0.239583       GOP       GOP     GOP  
1971    0.038636       GOP       GOP     GOP  
1972    0.057019       GOP       GOP     GOP  
1973    0.113159       GOP       GOP     GOP  
1974    0.011168       GOP       GOP     GOP  
1975    0.001647       GOP       GOP     GOP  
1976   -0.010682       GOP       GOP     GOP  
1977    0.039648       GOP       GOP     GOP  
1978   -0.001921       GOP       GOP     GOP  
1979   -0.067207       Dem       Dem     Dem  
1980    0.076010       GOP       GOP     GOP  

[17 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
1654         29268         38235         69264  0.422557  0.552018      8967   
1655          3750         13826         18011  0.208206  0.767642     10076   
1656          1300          3789          5214  0.249329  0.726697      2489   
1657          5785          4480         10394  0.556571  0.431018      1305   
1658          3476          9353         13160  0.264134  0.710714      5877   
1659          1670          6226          8060  0.207196  0.772457      4556   
1660          8699         14478         23599  0.368617  0.613501      5779   
1661          5837          3476          9380  0.622281  0.370576      2361   
1662          7021          8511         15743  0.445976  0.540621      1490   
1663         23117         42440         67255  0.343722  0.631031     19323   
1664         74937         55339        134507  0.557123  0.411421     19598   
1665         10930         25741         37638  0.290398  0.683910     14811   
1666         35048         53224         91002  0.385134  0.584866     18176   
1667          8403         26499         35747  0.235069  0.741293     18096   
1668          1266          3527          4939  0.256327  0.714112      2261   
1669          9806         26228         36919  0.265608  0.710420     16422   
1670          4549          5758         10515  0.432620  0.547599      1209   
1671         21050         48062         71065  0.296208  0.676310     27012   
1672         20953         17012         39080  0.536157  0.435312      3941   
1673          2809         10711         13860  0.202670  0.772799      7902   
1674          2965          3983          7108  0.417136  0.560355      1018   
1675          1352          4395          5885  0.229737  0.746814      3043   
1676         14896         28394         44137  0.337495  0.643315     13498   
1677          8991         14177         23472  0.383052  0.603996      5186   
1678         17481         27556         46231  0.378123  0.596050     10075   
1679         70523         50593        124402  0.566896  0.406690     19930   
1680          2879          9070         12423  0.231748  0.730097      6191   
1681          7079         11283         19009  0.372403  0.593561      4204   
1682         17328         52870         72013  0.240623  0.734173     35542   
1683          5228         15502         21350  0.244871  0.726089     10274   
...            ...           ...           ...       ...       ...       ...   
1724          9086         17317         27072  0.335624  0.639665      8231   
1725          2291          4143          6595  0.347384  0.628203      1852   
1726          7772         11116         19303  0.402632  0.575869      3344   
1727         40967         35191         78264  0.523446  0.449645      5776   
1728          3715          6738         10723  0.346452  0.628369      3023   
1729         13074         49156         63615  0.205518  0.772711     36082   
1730          8290         10199         18813  0.440653  0.542125      1909   
1731         18377         20294         39454  0.465783  0.514371      1917   
1732         14057         26463         41374  0.339754  0.639605     12406   
1733         19208         42388         63078  0.304512  0.671993     23180   
1734          7451         21694         29764  0.250336  0.728867     14243   
1735         10486         14761         25638  0.409002  0.575747      4275   
1736          7279          6212         13743  0.529651  0.452012      1067   
1737          7008         21788         29451  0.237955  0.739805     14780   
1738          4645         16976         22182  0.209404  0.765305     12331   
1739          7438         23495         31663  0.234911  0.742033     16057   
1740          2186          3557          5982  0.365430  0.594617      1371   
1741          6520         10441         17440  0.373853  0.598681      3921   
1742           705           968          1700  0.414706  0.569412       263   
1743         34051         66265        103596  0.328690  0.639648     32214   
1744         12168          7304         19762  0.615727  0.369598      4864   
1745        298353        193607        510940  0.583930  0.378923    104746   
1746          6668          3302         10123  0.658698  0.326188      3366   
1747          3490          2560          6115  0.570728  0.418643       930   
1748         13953         13521         28769  0.485001  0.469985       432   
1749         21520         27360         49824  0.431920  0.549133      5840   
1750          6596         23613         30844  0.213850  0.765562     17017   
1751         19527         17410         37593  0.519432  0.463118      2117   
1752          3140         13815         17350  0.180980  0.796254     10675   
1753          3181          6367          9808  0.324327  0.649164      3186   

      per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
1654          -0.129461    NC  37001         66638    ...        356.5   
1655          -0.559436    NC  37003         17060    ...        143.1   
1656          -0.477369    NC  37005          5025    ...         47.5   
1657           0.125553    NC  37007         11072    ...         50.7   
1658          -0.446581    NC  37009         12486    ...         64.0   
1659          -0.565261    NC  37011          7657    ...         72.0   
1660          -0.244883    NC  37013         23468    ...         57.7   
1661           0.251706    NC  37015          9941    ...         30.4   
1662          -0.094645    NC  37017         16351    ...         40.2   
1663          -0.287309    NC  37019         56985    ...        126.8   
1664           0.145702    NC  37021        126201    ...        362.9   
1665          -0.393512    NC  37023         36116    ...        179.3   
1666          -0.199732    NC  37025         82445    ...        492.1   
1667          -0.506224    NC  37027         34338    ...        176.1   
1668          -0.457785    NC  37029          4520    ...         41.5   
1669          -0.444812    NC  37031         35124    ...        131.3   
1670          -0.114979    NC  37033         10736    ...         55.8   
1671          -0.380103    NC  37035         69102    ...        387.1   
1672           0.100844    NC  37037         35157    ...         93.1   
1673          -0.570130    NC  37039         12695    ...         60.3   
1674          -0.143219    NC  37041          7424    ...         85.8   
1675          -0.517077    NC  37043          5592    ...         49.3   
1676          -0.305821    NC  37045         42542    ...        211.3   
1677          -0.220944    NC  37047         24017    ...         62.0   
1678          -0.217927    NC  37049         45585    ...        146.0   
1679           0.160206    NC  37051        126092    ...        489.7   
1680          -0.498350    NC  37053         11153    ...         89.9   
1681          -0.221158    NC  37055         17614    ...         88.5   
1682          -0.493550    NC  37057         69994    ...        294.7   
1683          -0.481218    NC  37059         20418    ...        156.2   
...                 ...   ...    ...           ...    ...          ...   
1724          -0.304041    NC  37141         24036    ...         60.0   
1725          -0.280819    NC  37143          6621    ...         54.4   
1726          -0.173237    NC  37145         19008    ...        100.6   
1727           0.073801    NC  37147         76814    ...        257.9   
1728          -0.281917    NC  37149         10323    ...         86.3   
1729          -0.567193    NC  37151         60202    ...        181.1   
1730          -0.101472    NC  37153         19127    ...         98.4   
1731          -0.048588    NC  37155         41380    ...        141.3   
1732          -0.299850    NC  37157         41549    ...        165.6   
1733          -0.367482    NC  37159         61803    ...        270.7   
1734          -0.478531    NC  37161         28373    ...        120.2   
1735          -0.166745    NC  37163         26005    ...         67.1   
1736           0.077640    NC  37165         14020    ...        113.4   
1737          -0.501851    NC  37167         28276    ...        153.3   
1738          -0.555901    NC  37169         21396    ...        105.6   
1739          -0.507122    NC  37171         29096    ...        138.4   
1740          -0.229188    NC  37173          5705    ...         26.5   
1741          -0.224828    NC  37175         16469    ...         87.4   
1742          -0.154706    NC  37177          1775    ...         11.3   
1743          -0.310958    NC  37179         93389    ...        318.7   
1744           0.246129    NC  37181         20770    ...        179.2   
1745           0.205006    NC  37183        526805    ...       1078.8   
1746           0.332510    NC  37185          9777    ...         48.9   
1747           0.152085    NC  37187          6456    ...         38.0   
1748           0.015016    NC  37189         28168    ...        163.4   
1749          -0.117213    NC  37191         50988    ...        221.7   
1750          -0.551712    NC  37193         28852    ...         91.9   
1751           0.056314    NC  37195         38890    ...        220.6   
1752          -0.615274    NC  37197         16657    ...        114.7   
1753          -0.324837    NC  37199          9344    ...         57.0   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
1654      -0.002741     -0.013905    0.558698      0.400324   0.006680   
1655      -0.060903      0.052109    0.763445      0.202262  -0.004197   
1656      -0.063905      0.054459    0.708425      0.249660  -0.018272   
1657      -0.066081      0.058456    0.533150      0.457369   0.102132   
1658      -0.064234      0.053418    0.704852      0.249747  -0.005862   
1659      -0.035850      0.026995    0.694473      0.263464  -0.077984   
1660      -0.031885      0.020438    0.572141      0.393961  -0.041359   
1661      -0.035298      0.031877    0.493779      0.511853   0.123204   
1662      -0.060232      0.054596    0.587955      0.395158   0.047334   
1663      -0.041152      0.024082    0.598844      0.352643  -0.032187   
1664       0.001930     -0.019867    0.534118      0.406408   0.122697   
1665      -0.085530      0.071744    0.703462      0.263022   0.019552   
1666      -0.008498     -0.010986    0.555441      0.398614  -0.029425   
1667      -0.079306      0.069472    0.768188      0.202218   0.026895   
1668      -0.065797      0.051502    0.686541      0.273848  -0.027571   
1669      -0.024706      0.010101    0.632940      0.313694  -0.077480   
1670      -0.050148      0.038005    0.648292      0.341608   0.100693   
1671      -0.050439      0.033985    0.642560      0.315021  -0.033751   
1672       0.017000     -0.036230    0.495513      0.453753   0.060201   
1673      -0.060347      0.048026    0.731704      0.225028  -0.041096   
1674      -0.055251      0.038803    0.500417      0.470811  -0.059938   
1675      -0.051558      0.040090    0.659850      0.282942  -0.086964   
1676      -0.055858      0.045318    0.629288      0.337233  -0.014027   
1677      -0.073833      0.068417    0.582971      0.390218  -0.021025   
1678      -0.028941      0.011340    0.551267      0.403536  -0.044783   
1679      -0.027836      0.008639    0.415637      0.540910   0.008947   
1680      -0.083952      0.063819    0.716471      0.240975  -0.013626   
1681      -0.039656      0.020040    0.605037      0.334534   0.011477   
1682      -0.049273      0.035042    0.687555      0.275749  -0.046618   
1683      -0.031943      0.012601    0.640173      0.311955  -0.085916   
...             ...           ...         ...           ...        ...   
1724      -0.057745      0.041895    0.575204      0.377166  -0.064461   
1725      -0.067508      0.052157    0.587962      0.376431  -0.040241   
1726      -0.038446      0.025206    0.605740      0.363017   0.029871   
1727      -0.006418     -0.012953    0.410401      0.548566  -0.039244   
1728      -0.041033      0.025928    0.617779      0.328171  -0.010590   
1729      -0.038245      0.026673    0.724292      0.240334  -0.048418   
1730      -0.068941      0.059248    0.560783      0.409864   0.018658   
1731      -0.113168      0.101297    0.468764      0.499800  -0.045607   
1732      -0.049425      0.037015    0.678194      0.293717   0.038590   
1733      -0.060017      0.047072    0.636619      0.327628  -0.035374   
1734      -0.076630      0.066371    0.672995      0.286602  -0.055872   
1735      -0.033067      0.023622    0.587030      0.388301   0.011283   
1736      -0.050306      0.038389    0.469294      0.504924   0.017282   
1737      -0.055121      0.043172    0.698186      0.267221  -0.041619   
1738      -0.069573      0.057603    0.765609      0.196954   0.000304   
1739      -0.074581      0.063143    0.740241      0.227575  -0.001793   
1740      -0.093466      0.072970    0.580476      0.361278  -0.014141   
1741      -0.035401      0.020504    0.625484      0.319679   0.026803   
1742      -0.055717      0.046031    0.636334      0.357597   0.066922   
1743      -0.014305     -0.007837    0.542731      0.406080  -0.096917   
1744      -0.023945      0.013026    0.488261      0.501119   0.118663   
1745       0.039252     -0.063239    0.325834      0.614650  -0.053089   
1746      -0.019936      0.007992    0.465629      0.522528   0.139441   
1747      -0.019576      0.013593    0.506873      0.478009   0.088230   
1748       0.010314     -0.031435    0.478642      0.451322   0.008657   
1749      -0.022186      0.009084    0.527768      0.439985  -0.021365   
1750      -0.066512      0.058159    0.764995      0.205898  -0.000568   
1751      -0.013996      0.002743    0.494079      0.483659   0.030961   
1752      -0.054837      0.045818    0.745297      0.216717  -0.050956   
1753      -0.098832      0.087413    0.710776      0.241557   0.061612   

     Clinton_Dev  winner16  winner12     change  
1654   -0.022234       GOP       GOP        GOP  
1655   -0.005944       GOP       GOP        GOP  
1656    0.000331       GOP       GOP        GOP  
1657   -0.099203       Dem       Dem        Dem  
1658   -0.014387       GOP       GOP        GOP  
1659    0.056268       GOP       GOP        GOP  
1660    0.025344       GOP       GOP        GOP  
1661   -0.110428       Dem       Dem        Dem  
1662   -0.050818       GOP       Dem  GOPchange  
1663    0.008921       GOP       GOP        GOP  
1664   -0.150715       Dem       Dem        Dem  
1665   -0.027376       GOP       GOP        GOP  
1666    0.013480       GOP       GOP        GOP  
1667   -0.032851       GOP       GOP        GOP  
1668    0.017521       GOP       GOP        GOP  
1669    0.048085       GOP       GOP        GOP  
1670   -0.091012       GOP       GOP        GOP  
1671    0.018813       GOP       GOP        GOP  
1672   -0.082404       Dem       Dem        Dem  
1673    0.022359       GOP       GOP        GOP  
1674    0.053676       GOP       GOP        GOP  
1675    0.053205       GOP       GOP        GOP  
1676   -0.000262       GOP       GOP        GOP  
1677    0.007166       GOP       GOP        GOP  
1678    0.025413       GOP       GOP        GOP  
1679   -0.025986       Dem       Dem        Dem  
1680    0.009227       GOP       GOP        GOP  
1681   -0.037869       GOP       GOP        GOP  
1682    0.035126       GOP       GOP        GOP  
1683    0.067084       GOP       GOP        GOP  
...          ...       ...       ...        ...  
1724    0.041543       GOP       GOP        GOP  
1725    0.029047       GOP       GOP        GOP  
1726   -0.039615       GOP       GOP        GOP  
1727    0.025120       Dem       Dem        Dem  
1728   -0.018281       GOP       GOP        GOP  
1729    0.034816       GOP       GOP        GOP  
1730   -0.030789       GOP       Dem  GOPchange  
1731    0.034017       GOP       Dem  GOPchange  
1732   -0.046038       GOP       GOP        GOP  
1733    0.023116       GOP       GOP        GOP  
1734    0.036266       GOP       GOP        GOP  
1735   -0.020701       GOP       GOP        GOP  
1736   -0.024728       Dem       Dem        Dem  
1737    0.029266       GOP       GOP        GOP  
1738   -0.012450       GOP       GOP        GOP  
1739   -0.007336       GOP       GOP        GOP  
1740   -0.004152       GOP       GOP        GOP  
1741   -0.054174       GOP       GOP        GOP  
1742   -0.057109       GOP       GOP        GOP  
1743    0.077390       GOP       GOP        GOP  
1744   -0.114608       Dem       Dem        Dem  
1745    0.030720       Dem       Dem        Dem  
1746   -0.136170       Dem       Dem        Dem  
1747   -0.092718       Dem       Dem        Dem  
1748   -0.033680       Dem       GOP  Demchange  
1749    0.008064       GOP       GOP        GOP  
1750   -0.007952       GOP       GOP        GOP  
1751   -0.035773       Dem       Dem        Dem  
1752    0.035737       GOP       GOP        GOP  
1753   -0.082770       GOP       GOP        GOP  

[100 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
2043          2293          8445         11063  0.207267  0.763355      6152   
2044         12815         29858         44636  0.287100  0.668922     17043   
2045          5659         17169         24074  0.235067  0.713176     11510   
2046         15191         22755         39809  0.381597  0.571604      7564   
2047         15552         10816         27941  0.556601  0.387101      4736   
2048          3825         18130         22860  0.167323  0.793088     14305   
2049          8652         20729         30537  0.283328  0.678816     12077   
2050          4270         14257         19139  0.223105  0.744919      9987   
2051         56700        104441        168422  0.336654  0.620115     47741   
2052          3124          9067         12807  0.243929  0.707972      5943   
2053          4488         12314         17597  0.255043  0.699778      7826   
2054         22666         34311         59620  0.380174  0.575495     11645   
2055         26096         65960         96455  0.270551  0.683842     39864   
2056          3943         13466         18100  0.217845  0.743978      9523   
2057         12273         31086         45261  0.271161  0.686816     18813   
2058          3908         10381         14961  0.261212  0.693871      6473   
2059          4518         13265         18702  0.241578  0.709282      8747   
2060        383974        179894        583230  0.658358  0.308444    204080   
2061          4395         19698         25000  0.175800  0.787920     15303   
2062          5282         11478         17795  0.296825  0.645013      6196   
2063         39584         55660        100101  0.395441  0.556038     16076   
2064         15692         19301         36730  0.427226  0.525483      3609   
2065         24150         43163         70542  0.342349  0.611877     19013   
2066          2672          7763         10817  0.247019  0.717667      5091   
2067        335961        192328        554711  0.605651  0.346717    143633   
2068          5981         13419         20693  0.289035  0.648480      7438   
2069          2564          9567         12588  0.203686  0.760010      7003   
2070         17165         29577         48736  0.352204  0.606882     12412   
2071         28023         47506         79633  0.351902  0.596562     19483   
2072          4286         11164         16156  0.265288  0.691013      6878   
...            ...           ...           ...       ...       ...       ...   
2101          3711         11722         16186  0.229272  0.724206      8011   
2102         10926         23588         36217  0.301682  0.651296     12662   
2103          1201          4441          5875  0.204426  0.755915      3240   
2104          8136         12389         21742  0.374207  0.569819      4253   
2105          2068          6359          8842  0.233884  0.719181      4291   
2106          4072          9978         14647  0.278009  0.681232      5906   
2107          6325         16482         23814  0.265600  0.692114     10157   
2108          3443          7669         11513  0.299053  0.666117      4226   
2109         31463         38978         73968  0.425360  0.526958      7515   
2110          4323         15376         20475  0.211136  0.750965     11053   
2111          2874         14704         18387  0.156306  0.799695     11830   
2112         15629         35805         53739  0.290832  0.666276     20176   
2113          9905         17833         28955  0.342083  0.615887      7928   
2114          9733         16045         27491  0.354043  0.583646      6312   
2115          8841         19742         29618  0.298501  0.666554     10901   
2116          7237         14559         23481  0.308207  0.620033      7322   
2117          4143         18148         23110  0.179273  0.785288     14005   
2118         66581         96345        170868  0.389663  0.563856     29764   
2119        129922        109531        249937  0.519819  0.438234     20391   
2120         42130         48152         94073  0.447844  0.511858      6022   
2121         11895         26105         40088  0.296722  0.651192     14210   
2122          7530         17601         26533  0.283798  0.663363     10071   
2123          2667         10328         13584  0.196334  0.760306      7661   
2124          1332          3799          5393  0.246987  0.704432      2467   
2125         33036         75947        114254  0.289145  0.664721     42911   
2126          7841         19901         28992  0.270454  0.686431     12060   
2127         14670         31622         48550  0.302163  0.651329     16952   
2128          4287         11706         16938  0.253100  0.691109      7419   
2129         26440         31734         62287  0.424487  0.509480      5294   
2130          2484          7346         10396  0.238938  0.706618      4862   

      per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
2043          -0.556088    OH  39001         10787    ...         48.9   
2044          -0.381822    OH  39003         46458    ...        264.2   
2045          -0.478109    OH  39005         23826    ...        125.6   
2046          -0.190007    OH  39007         41781    ...        144.6   
2047           0.169500    OH  39009         26112    ...        128.6   
2048          -0.625766    OH  39011         22838    ...        114.5   
2049          -0.395487    OH  39013         30876    ...        132.3   
2050          -0.521814    OH  39015         18955    ...         91.5   
2051          -0.283461    OH  39017        164020    ...        788.2   
2052          -0.464043    OH  39019         12965    ...         73.1   
2053          -0.444735    OH  39021         20016    ...         93.5   
2054          -0.195320    OH  39023         62136    ...        348.0   
2055          -0.413291    OH  39025         93392    ...        436.5   
2056          -0.526133    OH  39027         17648    ...        102.9   
2057          -0.415656    OH  39029         45078    ...        202.7   
2058          -0.432658    OH  39031         15555    ...         65.4   
2059          -0.467704    OH  39033         19192    ...        109.0   
2060           0.349913    OH  39035        611512    ...       2800.0   
2061          -0.612120    OH  39037         24807    ...         88.5   
2062          -0.348188    OH  39039         17744    ...         94.9   
2063          -0.160598    OH  39041         96330    ...        393.2   
2064          -0.098258    OH  39043         38262    ...        306.4   
2065          -0.269527    OH  39045         70079    ...        289.8   
2066          -0.470648    OH  39047         10677    ...         71.4   
2067           0.258933    OH  39049        541751    ...       2186.1   
2068          -0.359445    OH  39051         20757    ...        105.3   
2069          -0.556323    OH  39053          9534    ...         66.3   
2070          -0.254678    OH  39055         50125    ...        233.4   
2071          -0.244660    OH  39057         81075    ...        390.5   
2072          -0.425724    OH  39059         16403    ...         76.8   
...                 ...   ...    ...           ...    ...          ...   
2101          -0.494934    OH  39117         15813    ...         85.8   
2102          -0.349615    OH  39119         35954    ...        129.5   
2103          -0.551489    OH  39121          5755    ...         36.8   
2104          -0.195612    OH  39123         21936    ...        162.5   
2105          -0.485297    OH  39125          8912    ...         47.1   
2106          -0.403223    OH  39127         14673    ...         88.4   
2107          -0.426514    OH  39129         23443    ...        111.1   
2108          -0.367063    OH  39131         11233    ...         65.2   
2109          -0.101598    OH  39133         74029    ...        331.2   
2110          -0.539829    OH  39135         19619    ...         99.7   
2111          -0.643389    OH  39137         18126    ...         71.5   
2112          -0.375444    OH  39139         55954    ...        251.3   
2113          -0.273804    OH  39141         28961    ...        113.3   
2114          -0.229602    OH  39143         28192    ...        149.2   
2115          -0.368053    OH  39145         30023    ...        130.3   
2116          -0.311827    OH  39147         24633    ...        103.0   
2117          -0.606015    OH  39149         23129    ...        121.2   
2118          -0.174193    OH  39151        176620    ...        652.9   
2119           0.081585    OH  39153        259389    ...       1312.6   
2120          -0.064014    OH  39155         98703    ...        340.1   
2121          -0.354470    OH  39157         39855    ...        163.1   
2122          -0.379565    OH  39159         24947    ...        121.1   
2123          -0.563972    OH  39161         13586    ...         70.3   
2124          -0.457445    OH  39163          5352    ...         32.6   
2125          -0.375575    OH  39165        108008    ...        530.0   
2126          -0.415977    OH  39167         28798    ...         97.8   
2127          -0.349166    OH  39169         49356    ...        206.4   
2128          -0.438009    OH  39171         17286    ...         89.4   
2129          -0.084994    OH  39173         61967    ...        203.3   
2130          -0.467680    OH  39175         10254    ...         55.6   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
2043      -0.150293      0.143072    0.804058      0.162483   0.040702   
2044      -0.076002      0.048964    0.635385      0.314494  -0.033537   
2045      -0.104184      0.074168    0.711024      0.237071  -0.002152   
2046      -0.168031      0.143419    0.733727      0.218960   0.162123   
2047      -0.104704      0.076210    0.536877      0.394923   0.149775   
2048      -0.079765      0.057385    0.740932      0.203668  -0.052156   
2049      -0.164463      0.147076    0.735475      0.215694   0.056659   
2050      -0.142129      0.129197    0.813653      0.148965   0.068734   
2051      -0.024777     -0.003138    0.587711      0.358311  -0.032404   
2052      -0.172268      0.154405    0.789514      0.165025   0.081541   
2053      -0.135944      0.107652    0.728006      0.222178   0.028228   
2054      -0.102992      0.074722    0.660857      0.291441   0.085362   
2055      -0.043544      0.014331    0.675433      0.272294  -0.008409   
2056      -0.095731      0.078747    0.731278      0.217227  -0.012700   
2057      -0.158118      0.137147    0.751894      0.199677   0.065077   
2058      -0.178582      0.159509    0.771996      0.182145   0.078126   
2059      -0.133943      0.106896    0.766221      0.184311   0.056938   
2060      -0.030023      0.006774    0.423942      0.534319   0.115498   
2061      -0.090657      0.072598    0.780426      0.171215  -0.007494   
2062      -0.122359      0.085105    0.701393      0.243753   0.056381   
2063       0.020365     -0.056232    0.443289      0.485297  -0.112750   
2064      -0.120812      0.090195    0.641200      0.306656   0.115717   
2065      -0.069058      0.039180    0.615170      0.327824   0.003294   
2066      -0.134643      0.113002    0.741759      0.213062   0.024092   
2067       0.004537     -0.037114    0.401078      0.545815   0.054360   
2068      -0.134437      0.093438    0.726559      0.219556   0.078078   
2069      -0.154820      0.139913    0.754166      0.205980  -0.005844   
2070      -0.032734      0.006303    0.601577      0.339706  -0.005305   
2071      -0.030806     -0.003907    0.513904      0.422646  -0.082658   
2072      -0.175241      0.153855    0.747148      0.204825   0.056135   
...             ...           ...         ...           ...        ...   
2101      -0.136250      0.113190    0.759162      0.190320   0.034956   
2102      -0.152426      0.127683    0.719867      0.229906   0.068570   
2103      -0.157347      0.148096    0.817754      0.148300   0.061839   
2104      -0.137008      0.099223    0.692537      0.248671   0.122718   
2105      -0.151552      0.130312    0.756872      0.190602   0.037690   
2106      -0.189312      0.170225    0.783106      0.171068   0.101875   
2107      -0.132600      0.107163    0.743719      0.212573   0.051605   
2108      -0.189685      0.173372    0.778189      0.185759   0.112072   
2109      -0.089060      0.061397    0.619736      0.320778   0.092778   
2110      -0.094945      0.078045    0.788477      0.162876   0.037513   
2111      -0.077502      0.051433    0.713567      0.228887  -0.086129   
2112      -0.098506      0.075487    0.699624      0.255945   0.033348   
2113      -0.137701      0.112382    0.721561      0.234284   0.105674   
2114      -0.143793      0.105106    0.711509      0.234204   0.127864   
2115      -0.182197      0.166171    0.735299      0.221942   0.068744   
2116      -0.136806      0.091271    0.709273      0.235283   0.089240   
2117      -0.082952      0.063250    0.750431      0.199928  -0.034857   
2118      -0.099036      0.071511    0.644954      0.302893   0.081098   
2119      -0.047460      0.019173    0.525878      0.420785   0.087643   
2120      -0.154428      0.131474    0.674361      0.276496   0.162503   
2121      -0.142771      0.113744    0.746499      0.203995   0.095307   
2122      -0.058769      0.024127    0.643889      0.297269  -0.019474   
2123      -0.092419      0.065989    0.732867      0.210872  -0.027440   
2124      -0.198080      0.181636    0.810943      0.150410   0.106511   
2125      -0.006268     -0.026210    0.554351      0.384895  -0.110370   
2126      -0.123080      0.098855    0.728037      0.218318   0.041606   
2127      -0.081418      0.054643    0.720472      0.232058   0.069144   
2128      -0.154456      0.120531    0.749297      0.196946   0.058188   
2129      -0.085398      0.041538    0.581167      0.352582   0.071687   
2130      -0.147448      0.116214    0.774277      0.173216   0.067659   

     Clinton_Dev  winner16  winner12     change  
2043   -0.044785       GOP       GOP        GOP  
2044    0.027394       GOP       GOP        GOP  
2045    0.002004       GOP       GOP        GOP  
2046   -0.162637       GOP       Dem  GOPchange  
2047   -0.161678       Dem       Dem        Dem  
2048    0.036345       GOP       GOP        GOP  
2049   -0.067634       GOP       GOP        GOP  
2050   -0.074140       GOP       GOP        GOP  
2051    0.021656       GOP       GOP        GOP  
2052   -0.078904       GOP       GOP        GOP  
2053   -0.032865       GOP       GOP        GOP  
2054   -0.088733       GOP       GOP        GOP  
2055    0.001743       GOP       GOP        GOP  
2056   -0.000619       GOP       GOP        GOP  
2057   -0.071483       GOP       GOP        GOP  
2058   -0.079068       GOP       GOP        GOP  
2059   -0.057267       GOP       GOP        GOP  
2060   -0.124039       Dem       Dem        Dem  
2061   -0.004585       GOP       GOP        GOP  
2062   -0.053072       GOP       GOP        GOP  
2063    0.089856       GOP       GOP        GOP  
2064   -0.120570       GOP       Dem  GOPchange  
2065   -0.014525       GOP       GOP        GOP  
2066   -0.033956       GOP       GOP        GOP  
2067   -0.059835       Dem       Dem        Dem  
2068   -0.069479       GOP       GOP        GOP  
2069    0.002294       GOP       GOP        GOP  
2070   -0.012498       GOP       GOP        GOP  
2071    0.070744       GOP       GOP        GOP  
2072   -0.060463       GOP       GOP        GOP  
...          ...       ...       ...        ...  
2101   -0.038952       GOP       GOP        GOP  
2102   -0.071775       GOP       GOP        GOP  
2103   -0.056125       GOP       GOP        GOP  
2104   -0.125535       GOP       Dem  GOPchange  
2105   -0.043282       GOP       GOP        GOP  
2106   -0.106941       GOP       GOP        GOP  
2107   -0.053027       GOP       GOP        GOP  
2108   -0.113294       GOP       GOP        GOP  
2109   -0.104581       GOP       Dem  GOPchange  
2110   -0.048259       GOP       GOP        GOP  
2111    0.072581       GOP       GOP        GOP  
2112   -0.034887       GOP       GOP        GOP  
2113   -0.107798       GOP       GOP        GOP  
2114   -0.119839       GOP       Dem  GOPchange  
2115   -0.076559       GOP       GOP        GOP  
2116   -0.072923       GOP       GOP        GOP  
2117    0.020655       GOP       GOP        GOP  
2118   -0.086771       GOP       GOP        GOP  
2119   -0.099034       Dem       Dem        Dem  
2120   -0.171348       GOP       Dem  GOPchange  
2121   -0.092727       GOP       GOP        GOP  
2122    0.013472       GOP       GOP        GOP  
2123    0.014538       GOP       GOP        GOP  
2124   -0.096577       GOP       GOP        GOP  
2125    0.095750       GOP       GOP        GOP  
2126   -0.052136       GOP       GOP        GOP  
2127   -0.070105       GOP       GOP        GOP  
2128   -0.056154       GOP       GOP        GOP  
2129   -0.071905       GOP       Dem  GOPchange  
2130   -0.065722       GOP       GOP        GOP  

[88 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
2992          3780          5983         10107  0.373998  0.591966      2203   
2993          4136          3428          7926  0.521827  0.432501       708   
2994          7881         13595         22514  0.350049  0.603846      5714   
2995          4953          4125          9491  0.521863  0.434622       828   
2996         53358         67192        127497  0.418504  0.527008     13834   
2997          2531          4049          6921  0.365699  0.585031      1518   
2998          2948          5412          8719  0.338112  0.620713      2464   
2999          9634         15345         26429  0.364524  0.580612      5711   
3000         11875         17912         31471  0.377332  0.569159      6037   
3001          4225          8645         13548  0.311854  0.638102      4420   
3002         13525         14160         29287  0.461809  0.483491       635   
3003          3426          3844          7678  0.446210  0.500651       418   
3004        217506         71270        304729  0.713769  0.233880    146236   
3005         13968         26643         42818  0.326218  0.622238     12675   
3006          8026          8584         17398  0.461317  0.493390       558   
3007         11342          9657         22185  0.511246  0.435294      1685   
3008          9025         11487         22029  0.409687  0.521449      2462   
3009         27271         23301         54080  0.504271  0.430862      3970   
3010           666          1897          2651  0.251226  0.715579      1231   
3011         17391         31044         51094  0.340373  0.607586     13653   
3012          1583          2787          4507  0.351231  0.618371      1204   
3013         10047         12347         24051  0.417737  0.513367      2300   
3014          9121          8693         18791  0.485392  0.462615       428   
3015          2700          6210          9315  0.289855  0.666667      3510   
3016          6669          4809         12123  0.550111  0.396684      1860   
3017          1273          2090          3477  0.366120  0.601093       817   
3018          3821          4907          9202  0.415236  0.533254      1086   
3019         16559         23409         42324  0.391244  0.553090      6850   
3020          4100          7188         11736  0.349352  0.612474      3088   
3021         35770         36025         75825  0.471744  0.475107       255   
...            ...           ...           ...       ...       ...       ...   
3034          5886         13255         19924  0.295423  0.665278      7369   
3035          8103         11677         20837  0.388876  0.560397      3574   
3036         38117         51579         95162  0.400549  0.542013     13462   
3037         20167         30458         53368  0.377886  0.570717     10291   
3038          1345          2228          3746  0.359050  0.594768       883   
3039          8380         11260         21089  0.397364  0.533928      2880   
3040          7568         13864         22691  0.333524  0.610991      6296   
3041         18524         17310         38123  0.485901  0.454057      1214   
3042          2671          4562          7560  0.353307  0.603439      1891   
3043         42506         46620         93678  0.453746  0.497662      4114   
3044          3577          4021          7962  0.449259  0.505024       444   
3045         39336         31483         75043  0.524179  0.419533      7853   
3046          2171          4564          7029  0.308863  0.649310      2393   
3047         16050         15871         33848  0.474179  0.468890       179   
3048          2846          4625          7767  0.366422  0.595468      1779   
3049          6056         12742         19697  0.307458  0.646901      6686   
3050         22636         32368         58290  0.388334  0.555293      9732   
3051         17496         26123         46819  0.373694  0.557957      8627   
3052          2398          6589          9417  0.254646  0.699692      4191   
3053          5645          7370         13581  0.415654  0.542670      1725   
3054          6351          6994         14193  0.447474  0.492778       643   
3055          4769          8169         13453  0.354493  0.607225      3400   
3056         18706         28848         50570  0.369903  0.570457     10142   
3057          3283          5404          9059  0.362402  0.596534      2121   
3058         20854         51729         76246  0.273509  0.678449     30875   
3059         79199        145519        236269  0.335207  0.615904     66320   
3060          8303         16013         25491  0.325723  0.628182      7710   
3061          3802          7669         11961  0.317866  0.641167      3867   
3062         37054         43447         85892  0.431402  0.505833      6393   
3063         14232         21502         37712  0.377387  0.570163      7270   

      per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
2992          -0.217968    WI  55001         10263    ...         32.3   
2993           0.089326    WI  55003          8342    ...         15.5   
2994          -0.253798    WI  55005         22583    ...         53.2   
2995           0.087241    WI  55007          9759    ...         10.2   
2996          -0.108505    WI  55009        128514    ...        468.2   
2997          -0.219332    WI  55011          7008    ...         20.2   
2998          -0.282601    WI  55013          8634    ...         18.8   
2999          -0.216088    WI  55015         26336    ...        153.9   
3000          -0.191827    WI  55017         30914    ...         61.9   
3001          -0.326247    WI  55019         13740    ...         28.7   
3002          -0.021682    WI  55021         30460    ...         74.2   
3003          -0.054441    WI  55023          7791    ...         29.2   
3004           0.479889    WI  55025        302845    ...        407.7   
3005          -0.296020    WI  55027         44379    ...        101.4   
3006          -0.032073    WI  55029         17607    ...         57.6   
3007           0.075952    WI  55031         22862    ...         33.9   
3008          -0.111762    WI  55033         21899    ...         51.6   
3009           0.073410    WI  55035         54595    ...        154.8   
3010          -0.464353    WI  55037          2615    ...          9.1   
3011          -0.267213    WI  55039         53272    ...        141.2   
3012          -0.267140    WI  55041          4643    ...          9.2   
3013          -0.095630    WI  55043         24160    ...         44.7   
3014           0.022777    WI  55045         19302    ...         63.1   
3015          -0.376812    WI  55047          9657    ...         54.5   
3016           0.153427    WI  55049         12515    ...         31.1   
3017          -0.234973    WI  55051          3620    ...          7.8   
3018          -0.118018    WI  55053          9290    ...         20.7   
3019          -0.161847    WI  55055         44136    ...        150.4   
3020          -0.263122    WI  55057         11781    ...         34.8   
3021          -0.003363    WI  55059         80661    ...        611.9   
...                 ...   ...    ...           ...    ...          ...   
3034          -0.369855    WI  55083         19727    ...         37.7   
3035          -0.171522    WI  55085         21577    ...         32.3   
3036          -0.141464    WI  55087         94237    ...        277.2   
3037          -0.192831    WI  55089         55565    ...        370.7   
3038          -0.235718    WI  55091          3696    ...         32.2   
3039          -0.136564    WI  55093         20920    ...         71.5   
3040          -0.277467    WI  55095         22494    ...         48.4   
3041           0.031844    WI  55097         39186    ...         87.4   
3042          -0.250132    WI  55099          7870    ...         11.3   
3043          -0.043916    WI  55101        102937    ...        587.7   
3044          -0.055765    WI  55103          8636    ...         30.7   
3045           0.104647    WI  55105         80462    ...        223.3   
3046          -0.340447    WI  55107          7171    ...         16.2   
3047           0.005288    WI  55111         31832    ...         74.6   
3048          -0.229046    WI  55113          9003    ...         13.2   
3049          -0.339443    WI  55115         20222    ...         47.0   
3050          -0.166958    WI  55117         63272    ...        225.9   
3051          -0.184263    WI  55109         46009    ...        116.8   
3052          -0.445046    WI  55119          9486    ...         21.2   
3053          -0.127016    WI  55121         13456    ...         39.3   
3054          -0.045304    WI  55123         14215    ...         37.6   
3055          -0.252732    WI  55125         13782    ...         25.0   
3056          -0.200554    WI  55127         52115    ...        184.2   
3057          -0.234132    WI  55129          9242    ...         20.0   
3058          -0.404939    WI  55131         78558    ...        306.2   
3059          -0.280697    WI  55133        241084    ...        709.4   
3060          -0.302460    WI  55135         25801    ...         70.1   
3061          -0.323301    WI  55137         12017    ...         39.1   
3062          -0.074431    WI  55139         88814    ...        384.3   
3063          -0.192777    WI  55141         38762    ...         94.2   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
2992      -0.165513      0.139564    0.776206      0.180508   0.184240   
2993      -0.123942      0.094932    0.613173      0.321641   0.180672   
2994      -0.131862      0.098466    0.736349      0.211629   0.132502   
2995      -0.095516      0.066039    0.582163      0.349683   0.147541   
2996      -0.067303      0.023266    0.602397      0.336663   0.075389   
2997      -0.143577      0.106721    0.735155      0.210820   0.150124   
2998      -0.122972      0.094769    0.695729      0.246659   0.075016   
2999      -0.071267      0.029314    0.651332      0.288877   0.070720   
3000      -0.114711      0.071941    0.711366      0.232713   0.142207   
3001      -0.137418      0.099965    0.794629      0.164891   0.156527   
3002      -0.101487      0.056242    0.694117      0.248399   0.210626   
3003      -0.147039      0.107377    0.736958      0.209103   0.236307   
3004       0.002550     -0.041703    0.417227      0.509532   0.183347   
3005      -0.096167      0.054628    0.746899      0.206064   0.124661   
3006      -0.069040      0.032835    0.626342      0.308535   0.132951   
3007      -0.138522      0.098578    0.653686      0.282663   0.218392   
3008      -0.106455      0.055218    0.638525      0.298115   0.117076   
3009      -0.056549      0.005585    0.574954      0.357029   0.144093   
3010      -0.112828      0.087281    0.744337      0.201010   0.028758   
3011      -0.079285      0.038263    0.698316      0.245876   0.090730   
3012      -0.170199      0.150570    0.708090      0.239360   0.089719   
3013      -0.144100      0.088906    0.695417      0.247519   0.182050   
3014      -0.094652      0.056025    0.702649      0.239524   0.240034   
3015      -0.102606      0.068241    0.742453      0.207256   0.075786   
3016      -0.097032      0.052936    0.696655      0.244163   0.299971   
3017      -0.126421      0.107170    0.679447      0.259314   0.078354   
3018      -0.154947      0.113447    0.702909      0.244307   0.169655   
3019      -0.064982      0.020895    0.663945      0.275823   0.110855   
3020      -0.180059      0.154109    0.767628      0.187645   0.155153   
3021      -0.084138      0.041911    0.598853      0.344750   0.123746   
...             ...           ...         ...           ...        ...   
3034      -0.151173      0.123330    0.758603      0.189229   0.093325   
3035      -0.094927      0.054998    0.674523      0.264692   0.114125   
3036      -0.082966      0.040150    0.630800      0.306105   0.088787   
3037       0.034594     -0.077011    0.507454      0.422257  -0.063263   
3038      -0.148256      0.109649    0.733734      0.211558   0.138967   
3039      -0.090830      0.037608    0.644506      0.291182   0.110578   
3040      -0.113439      0.074181    0.710530      0.231249   0.099539   
3041      -0.076851      0.030461    0.620968      0.315294   0.166911   
3042      -0.139959      0.110555    0.728888      0.215293   0.125449   
3043      -0.060034      0.019962    0.589030      0.359554   0.091368   
3044      -0.125544      0.091059    0.747900      0.199306   0.242876   
3045      -0.086767      0.040571    0.663351      0.283756   0.243818   
3046      -0.164014      0.137108    0.740478      0.208102   0.091168   
3047      -0.113846      0.065868    0.694897      0.249618   0.226006   
3048      -0.131412      0.102743    0.594682      0.340115  -0.000786   
3049      -0.137107      0.102098    0.715840      0.228155   0.068939   
3050      -0.059826      0.013473    0.660382      0.281341   0.105090   
3051      -0.058265      0.004261    0.601819      0.331866   0.043862   
3052      -0.141833      0.109665    0.771183      0.180800   0.071491   
3053      -0.149224      0.118844    0.725649      0.222068   0.182979   
3054      -0.117492      0.075261    0.721656      0.227415   0.228878   
3055      -0.075851      0.045986    0.623559      0.312105   0.016334   
3056      -0.062065      0.014724    0.620446      0.317953   0.049989   
3057      -0.117472      0.088852    0.692328      0.249066   0.095794   
3058      -0.020999     -0.017967    0.655162      0.285467  -0.023287   
3059       0.013257     -0.054265    0.531777      0.399166  -0.084127   
3060      -0.122516      0.085994    0.738824      0.206946   0.110642   
3061      -0.125672      0.095440    0.745960      0.204905   0.104793   
3062      -0.079891      0.032113    0.635268      0.304854   0.129435   
3063      -0.101072      0.062321    0.708775      0.234226   0.138612   

     Clinton_Dev  winner16  winner12     change  
2992   -0.193490       GOP       Dem  GOPchange  
2993   -0.200185       Dem       Dem        Dem  
2994   -0.138420       GOP       GOP        GOP  
2995   -0.172180       Dem       Dem        Dem  
2996   -0.081841       GOP       GOP        GOP  
2997   -0.154878       GOP       Dem  GOPchange  
2998   -0.091453       GOP       GOP        GOP  
2999   -0.075647       GOP       GOP        GOP  
3000   -0.144618       GOP       GOP        GOP  
3001   -0.146963       GOP       GOP        GOP  
3002   -0.213410       GOP       Dem  GOPchange  
3003   -0.237107       GOP       Dem  GOPchange  
3004   -0.204237       Dem       Dem        Dem  
3005   -0.120154       GOP       GOP        GOP  
3006   -0.152782       GOP       Dem  GOPchange  
3007   -0.228584       Dem       Dem        Dem  
3008   -0.111573       GOP       Dem  GOPchange  
3009   -0.147243       Dem       Dem        Dem  
3010   -0.050216       GOP       GOP        GOP  
3011   -0.094497       GOP       GOP        GOP  
3012   -0.111872       GOP       Dem  GOPchange  
3013   -0.170218       GOP       Dem  GOPchange  
3014   -0.245868       Dem       Dem        Dem  
3015   -0.082599       GOP       GOP        GOP  
3016   -0.305948       Dem       Dem        Dem  
3017   -0.106806       GOP       GOP        GOP  
3018   -0.170929       GOP       Dem  GOPchange  
3019   -0.115421       GOP       GOP        GOP  
3020   -0.161708       GOP       Dem  GOPchange  
3021   -0.126994       GOP       Dem  GOPchange  
...          ...       ...       ...        ...  
3034   -0.106193       GOP       GOP        GOP  
3035   -0.124183       GOP       GOP        GOP  
3036   -0.094443       GOP       GOP        GOP  
3037    0.044371       GOP       GOP        GOP  
3038   -0.147491       GOP       Dem  GOPchange  
3039   -0.106182       GOP       GOP        GOP  
3040   -0.102275       GOP       GOP        GOP  
3041   -0.170607       Dem       Dem        Dem  
3042   -0.138014       GOP       Dem  GOPchange  
3043   -0.094192       GOP       Dem  GOPchange  
3044   -0.249953       GOP       Dem  GOPchange  
3045   -0.240424       Dem       Dem        Dem  
3046   -0.100761       GOP       GOP        GOP  
3047   -0.224561       Dem       Dem        Dem  
3048   -0.026308       GOP       Dem  GOPchange  
3049   -0.079303       GOP       GOP        GOP  
3050   -0.106993       GOP       GOP        GOP  
3051   -0.041828       GOP       GOP        GOP  
3052   -0.073846       GOP       GOP        GOP  
3053   -0.193586       GOP       Dem  GOPchange  
3054   -0.220059       GOP       Dem  GOPchange  
3055   -0.042389       GOP       GOP        GOP  
3056   -0.051950       GOP       GOP        GOP  
3057   -0.113336       GOP       GOP        GOP  
3058    0.011958       GOP       GOP        GOP  
3059    0.063959       GOP       GOP        GOP  
3060   -0.118777       GOP       GOP        GOP  
3061   -0.112961       GOP       GOP        GOP  
3062   -0.126548       GOP       Dem  GOPchange  
3063   -0.143161       GOP       GOP        GOP  

[72 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
1231          1732          4201          6179  0.280304  0.679883      2469   
1232          1663          2585          4513  0.368491  0.572790       922   
1233         17932         33812         55153  0.325132  0.613058     15880   
1234          4877          9090         14688  0.332040  0.618873      4213   
1235          4448          8469         13572  0.327734  0.624005      4021   
1236          2238          4704          7457  0.300121  0.630817      2466   
1237          1156          2158          3486  0.331612  0.619048      1002   
1238          9109         19197         30265  0.300975  0.634297     10088   
1239         21641         28327         52932  0.408845  0.535158      6686   
1240          4108          5539         10221  0.401918  0.541923      1431   
1241         29496         38646         71882  0.410339  0.537631      9150   
1242          4740         11025         16490  0.287447  0.668587      6285   
1243         24154         31489         58786  0.410880  0.535655      7335   
1244          7270         14241         23272  0.312393  0.611937      6971   
1245          5137          8674         14567  0.352646  0.595455      3537   
1246          4302          8680         13647  0.315234  0.636037      4378   
1247          5378          9120         15434  0.348451  0.590903      3742   
1248          4250          8507         13385  0.317520  0.635562      4257   
1249         16490         21635         40564  0.406518  0.533355      5145   
1250          2110          4354          6833  0.308796  0.637202      2244   
1251          6431         11112         18467  0.348243  0.601722      4681   
1252          3923          8580         13140  0.298554  0.652968      4657   
1253         24534         27608         55686  0.440578  0.495780      3074   
1254          6972         10616         18774  0.371365  0.565463      3644   
1255        102744         84174        196135  0.523843  0.429164     18570   
1256          3794          8124         12472  0.304201  0.651379      4330   
1257          2925          4019          7313  0.399973  0.549569      1094   
1258         20964         27412         51460  0.407384  0.532686      6448   
1259          5665          9878         16442  0.344544  0.600778      4213   
1260          4799         14094         19880  0.241398  0.708954      9295   
...            ...           ...           ...       ...       ...       ...   
1284          5827         10305         17149  0.339787  0.600910      4478   
1285          3539          6704         10765  0.328751  0.622759      3165   
1286         15655         23877         42379  0.369405  0.563416      8222   
1287          1565          5386          7301  0.214354  0.737707      3821   
1288         26859         43255         74101  0.362465  0.583730     16396   
1289          7874         16907         26556  0.296505  0.636655      9033   
1290          1286          3498          5008  0.256789  0.698482      2212   
1291         36640         35962         77114  0.475141  0.466349       678   
1292          6212         15174         22605  0.274806  0.671267      8962   
1293        342976        289127        663255  0.517110  0.435921     53849   
1294          3973          7228         11903  0.333781  0.607242      3255   
1295          3030          6827         10386  0.291739  0.657327      3797   
1296          1175          2069          3420  0.343567  0.604971       894   
1297          2705          7336         10597  0.255261  0.692271      4631   
1298          1044          2843          4062  0.257016  0.699902      1799   
1299          3556          8266         12529  0.283822  0.659749      4710   
1300         46276         90456        145405  0.318256  0.622097     44180   
1301          2400          4486          7215  0.332640  0.621760      2086   
1302          4287          8141         13036  0.328859  0.624501      3854   
1303         44395         45469         94198  0.471295  0.482696      1074   
1304          4873         13446         19243  0.253235  0.698748      8573   
1305          1369          2556          4151  0.329800  0.615755      1187   
1306         12547         19232         34044  0.368552  0.564916      6685   
1307         24553         49067         77994  0.314806  0.629112     24514   
1308          7529         14886         23765  0.316810  0.626383      7357   
1309          7493         17421         26157  0.286463  0.666017      9928   
1310         13258         17890         33213  0.399181  0.538645      4632   
1311        128025         50335        187201  0.683891  0.268882     77690   
1312        517842        228908        775450  0.667795  0.295194    288934   
1313          4436         10000         15279  0.290333  0.654493      5564   

      per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
1231          -0.399579    MI  26001          6086    ...         16.2   
1232          -0.204299    MI  26003          4603    ...         10.5   
1233          -0.287926    MI  26005         49199    ...        135.0   
1234          -0.286833    MI  26007         14014    ...         51.8   
1235          -0.296272    MI  26009         13184    ...         49.6   
1236          -0.330696    MI  26011          7826    ...         43.8   
1237          -0.287435    MI  26013          3490    ...          9.9   
1238          -0.333322    MI  26015         28483    ...        107.0   
1239          -0.126313    MI  26017         51077    ...        243.7   
1240          -0.140006    MI  26019          9847    ...         54.8   
1241          -0.127292    MI  26021         72322    ...        276.2   
1242          -0.381140    MI  26023         16278    ...         89.4   
1243          -0.124775    MI  26025         58231    ...        192.8   
1244          -0.299545    MI  26027         22461    ...        106.7   
1245          -0.242809    MI  26029         14064    ...         62.3   
1246          -0.320803    MI  26031         13288    ...         36.6   
1247          -0.242452    MI  26033         15564    ...         24.7   
1248          -0.318043    MI  26035         13492    ...         54.8   
1249          -0.126837    MI  26037         39125    ...        133.1   
1250          -0.328406    MI  26039          6814    ...         25.3   
1251          -0.253479    MI  26041         18043    ...         31.7   
1252          -0.354414    MI  26043         12785    ...         34.4   
1253          -0.055202    MI  26045         54707    ...        187.3   
1254          -0.194098    MI  26047         17672    ...         69.9   
1255           0.094680    MI  26049        202699    ...        668.5   
1256          -0.347178    MI  26051         12552    ...         51.2   
1257          -0.149597    MI  26053          7576    ...         14.9   
1258          -0.125301    MI  26055         47901    ...        187.3   
1259          -0.256234    MI  26057         16011    ...         74.7   
1260          -0.467555    MI  26059         19081    ...         78.1   
...                 ...   ...    ...           ...    ...          ...   
1284          -0.261123    MI  26107         16879    ...         77.1   
1285          -0.294008    MI  26109         10922    ...         23.0   
1286          -0.194011    MI  26111         41808    ...        162.0   
1287          -0.523353    MI  26113          7024    ...         26.3   
1288          -0.221266    MI  26115         72682    ...        276.7   
1289          -0.340149    MI  26117         25383    ...         89.8   
1290          -0.441693    MI  26119          5051    ...         17.9   
1291           0.008792    MI  26121         76054    ...        344.9   
1292          -0.396461    MI  26123         21424    ...         59.6   
1293           0.081189    MI  26125        650306    ...       1385.7   
1294          -0.273460    MI  26127         11438    ...         51.9   
1295          -0.365588    MI  26129         10361    ...         38.5   
1296          -0.261404    MI  26131          3535    ...          5.2   
1297          -0.437010    MI  26133         10265    ...         41.5   
1298          -0.442885    MI  26135          4027    ...         15.3   
1299          -0.375928    MI  26137         11829    ...         46.9   
1300          -0.303841    MI  26139        132695    ...        468.2   
1301          -0.289120    MI  26141          7077    ...         20.3   
1302          -0.295643    MI  26143         13032    ...         47.1   
1303          -0.011402    MI  26145         97903    ...        250.2   
1304          -0.445513    MI  26151         18359    ...         44.8   
1305          -0.285955    MI  26153          4046    ...          7.2   
1306          -0.196364    MI  26155         33590    ...        133.1   
1307          -0.314306    MI  26147         73740    ...        226.1   
1308          -0.309573    MI  26149         23314    ...        122.4   
1309          -0.379554    MI  26157         26482    ...         69.4   
1310          -0.139463    MI  26159         32798    ...        125.5   
1311           0.415008    MI  26161        179016    ...        488.4   
1312           0.372602    MI  26163        814108    ...       2974.4   
1313          -0.364160    MI  26165         13859    ...         57.9   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
1231      -0.124231      0.093127    0.767359      0.183051   0.087476   
1232      -0.112065      0.066815    0.669596      0.276996   0.096807   
1233      -0.073128      0.023148    0.675162      0.266382   0.062103   
1234      -0.135279      0.098108    0.727853      0.218387   0.108980   
1235      -0.059630      0.023505    0.661054      0.278537   0.037049   
1236      -0.168701      0.112800    0.773480      0.180208   0.142664   
1237      -0.119391      0.084377    0.706112      0.254113   0.087064   
1238      -0.102634      0.049703    0.719298      0.223416   0.085001   
1239      -0.115794      0.070468    0.694297      0.250056   0.159139   
1240      -0.073659      0.026944    0.659431      0.281708   0.117507   
1241      -0.052383      0.009313    0.566006      0.384889   0.028375   
1242      -0.113462      0.080370    0.729102      0.219866   0.060515   
1243      -0.091773      0.049007    0.613162      0.333681   0.077507   
1244      -0.114436      0.048293    0.699191      0.251220   0.087254   
1245      -0.069424      0.026841    0.637268      0.300808   0.041812   
1246      -0.123432      0.087873    0.708745      0.236435   0.072708   
1247      -0.107729      0.059035    0.589902      0.349567  -0.001001   
1248      -0.152166      0.117626    0.739678      0.210228   0.104116   
1249      -0.058325      0.006070    0.615322      0.321020   0.081967   
1250      -0.130594      0.087745    0.745460      0.206216   0.108258   
1251      -0.113432      0.073373    0.689088      0.249798   0.087366   
1252      -0.088775      0.051638    0.687293      0.249403   0.034325   
1253      -0.069631      0.016993    0.606845      0.331818   0.111065   
1254      -0.037474     -0.014720    0.590187      0.343149   0.024724   
1255      -0.112430      0.074909    0.561914      0.389927   0.132750   
1256      -0.154690      0.120707    0.763656      0.189408   0.112277   
1257      -0.135666      0.094976    0.647902      0.290378   0.098333   
1258      -0.028410     -0.021207    0.602817      0.332206   0.070132   
1259      -0.130504      0.086382    0.694060      0.253312   0.093282   
1260      -0.131014      0.094363    0.723933      0.222942   0.014980   
...             ...           ...         ...           ...        ...   
1284      -0.105441      0.057335    0.629915      0.308758   0.029005   
1285      -0.151381      0.113237    0.734201      0.209696   0.111442   
1286      -0.048697     -0.009250    0.584656      0.350880   0.021240   
1287      -0.109393      0.073556    0.763948      0.187602   0.026241   
1288      -0.137109      0.094022    0.708417      0.238001   0.124687   
1289      -0.153835      0.099917    0.726214      0.221358   0.089560   
1290      -0.148873      0.118795    0.786692      0.166718   0.088209   
1291      -0.109128      0.060295    0.610264      0.339604   0.143916   
1292      -0.132354      0.089770    0.734973      0.213973   0.063706   
1293      -0.019645     -0.020066    0.416685      0.522692  -0.019236   
1294      -0.108866      0.061779    0.695351      0.251917   0.088109   
1295      -0.170668      0.132571    0.755388      0.194845   0.098061   
1296      -0.104806      0.065791    0.744077      0.203002   0.139106   
1297      -0.132562      0.094122    0.735052      0.211671   0.042781   
1298      -0.153711      0.126770    0.784462      0.171787   0.084561   
1299      -0.111901      0.067307    0.696381      0.245087   0.036631   
1300      -0.006308     -0.044869    0.588647      0.348783  -0.033450   
1301      -0.118398      0.085657    0.750886      0.200235   0.129126   
1302      -0.146740      0.110306    0.741161      0.208554   0.116659   
1303      -0.084072      0.046387    0.571244      0.382055   0.088548   
1304      -0.139597      0.101711    0.763604      0.185707   0.064857   
1305      -0.131149      0.086343    0.692166      0.246445   0.076411   
1306      -0.143415      0.089715    0.729348      0.213179   0.164432   
1307      -0.144171      0.099197    0.709763      0.236244   0.080651   
1308      -0.116663      0.069851    0.720044      0.232032   0.093660   
1309      -0.153195      0.117833    0.755834      0.194268   0.089817   
1310      -0.097435      0.046541    0.659453      0.287956   0.120809   
1311       0.009141     -0.046179    0.324863      0.603924   0.055981   
1312      -0.063377      0.032838    0.424179      0.543890   0.128985   
1313      -0.122179      0.079271    0.710348      0.234596   0.055855   

     Clinton_Dev  winner16  winner12     change  
1231   -0.097253       GOP       GOP        GOP  
1232   -0.091495       GOP       GOP        GOP  
1233   -0.058750       GOP       GOP        GOP  
1234   -0.113652       GOP       GOP        GOP  
1235   -0.049196       GOP       GOP        GOP  
1236   -0.119912       GOP       GOP        GOP  
1237   -0.077499       GOP       GOP        GOP  
1238   -0.077559       GOP       GOP        GOP  
1239   -0.158789       GOP       Dem  GOPchange  
1240   -0.120210       GOP       GOP        GOP  
1241   -0.025450       GOP       GOP        GOP  
1242   -0.067581       GOP       GOP        GOP  
1243   -0.077199       GOP       Dem  GOPchange  
1244   -0.061173       GOP       GOP        GOP  
1245   -0.051839       GOP       GOP        GOP  
1246   -0.078799       GOP       GOP        GOP  
1247    0.001115       GOP       GOP        GOP  
1248   -0.107292       GOP       GOP        GOP  
1249   -0.085499       GOP       GOP        GOP  
1250   -0.102579       GOP       GOP        GOP  
1251   -0.098445       GOP       GOP        GOP  
1252   -0.049151       GOP       GOP        GOP  
1253   -0.108760       GOP       Dem  GOPchange  
1254   -0.028216       GOP       GOP        GOP  
1255   -0.133917       Dem       Dem        Dem  
1256   -0.114793       GOP       GOP        GOP  
1257   -0.109595       GOP       Dem  GOPchange  
1258   -0.075178       GOP       GOP        GOP  
1259   -0.091232       GOP       GOP        GOP  
1260   -0.018457       GOP       GOP        GOP  
...          ...       ...       ...        ...  
1284   -0.031028       GOP       GOP        GOP  
1285   -0.119054       GOP       GOP        GOP  
1286   -0.018525       GOP       GOP        GOP  
1287   -0.026752       GOP       GOP        GOP  
1288   -0.124463       GOP       Dem  GOPchange  
1289   -0.075147       GOP       GOP        GOP  
1290   -0.090071       GOP       GOP        GOP  
1291   -0.135537       Dem       Dem        Dem  
1292   -0.060834       GOP       GOP        GOP  
1293    0.005581       Dem       Dem        Dem  
1294   -0.081865       GOP       GOP        GOP  
1295   -0.096894       GOP       GOP        GOP  
1296   -0.140565       GOP       GOP        GOP  
1297   -0.043590       GOP       GOP        GOP  
1298   -0.085229       GOP       GOP        GOP  
1299   -0.038735       GOP       GOP        GOP  
1300    0.030527       GOP       GOP        GOP  
1301   -0.132405       GOP       GOP        GOP  
1302   -0.120305       GOP       GOP        GOP  
1303   -0.089239       GOP       Dem  GOPchange  
1304   -0.067528       GOP       GOP        GOP  
1305   -0.083355       GOP       GOP        GOP  
1306   -0.155373       GOP       Dem  GOPchange  
1307   -0.078563       GOP       GOP        GOP  
1308   -0.084779       GOP       GOP        GOP  
1309   -0.092194       GOP       GOP        GOP  
1310   -0.111225       GOP       Dem  GOPchange  
1311   -0.079967       Dem       Dem        Dem  
1312   -0.123905       Dem       Dem        Dem  
1313   -0.055737       GOP       GOP        GOP  

[83 rows x 77 columns]
     votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
551          1127          2456          3759  0.299814  0.653365      1329   
552           565          1393          2082  0.271374  0.669068       828   
553          2409          4072          6837  0.352348  0.595583      1663   
554          1813          4031          6096  0.297408  0.661253      2218   
555          1079          2135          3379  0.319325  0.631844      1056   
556          4672          8226         13690  0.341271  0.600877      3554   
557         32006         27382         63221  0.506256  0.433116      4624   
558          5517          7458         13984  0.394522  0.533324      1941   
559          5349          7199         13350  0.400674  0.539251      1850   
560          3966          5504         10137  0.391240  0.542961      1538   
561          2851          4895          8179  0.348576  0.598484      2044   
562          2163          4918          7457  0.290063  0.659515      2755   
563          1396          3466          5105  0.273457  0.678942      2070   
564          3305          6627         10435  0.316723  0.635074      3322   
565          1946          4755          7055  0.275833  0.673990      2809   
566          3578          5275          9386  0.381206  0.562007      1697   
567          9840         11583         22633  0.434763  0.511775      1743   
568          1676          4188          6186  0.270934  0.677013      2512   
569          2264          3739          6367  0.355583  0.587247      1475   
570          1463          2706          4405  0.332123  0.614302      1243   
571          2246          5870          8542  0.262936  0.687193      3624   
572          3236          5309          9098  0.355683  0.583535      2073   
573         10079         11249         22748  0.443072  0.494505      1170   
574          1985          4608          6862  0.289274  0.671524      2623   
575         15662         19288         37617  0.416354  0.512747      3626   
576           976          2721          3858  0.252981  0.705288      1745   
577          1201          2296          3703  0.324332  0.620038      1095   
578          2956          5688          9165  0.322531  0.620622      2732   
579          8178          9479         18713  0.437022  0.506546      1301   
580          3051          6743         10247  0.297746  0.658046      3692   
..            ...           ...           ...       ...       ...       ...   
620          8284          9549         19086  0.434035  0.500314      1265   
621          1314          5735          7348  0.178824  0.780484      4421   
622           552          2528          3197  0.172662  0.790741      1976   
623          1801          4875          6968  0.258467  0.699627      3074   
624          1395          3079          4674  0.298460  0.658751      1684   
625          2878          9659         13057  0.220418  0.739756      6781   
626           962          2692          3831  0.251109  0.702689      1730   
627        119671         93421        228420  0.523908  0.408988     26250   
628         15341         24441         42226  0.363307  0.578814      9100   
629          4272          4936          9693  0.440730  0.509233       664   
630           753          1820          2684  0.280551  0.678092      1067   
631          1269          3692          5158  0.246026  0.715781      2423   
632         40302         39083         84878  0.474823  0.460461      1219   
633          1649          4340          6270  0.262998  0.692185      2691   
634          2289         14761         17989  0.127244  0.820557     12472   
635         25085         19111         48910  0.512881  0.390738      5974   
636          3194          4968          8636  0.369847  0.575266      1774   
637           755          2108          3003  0.251415  0.701965      1353   
638          1920          3521          5768  0.332871  0.610437      1601   
639           843          2524          3526  0.239081  0.715825      1681   
640          5591          8710         14996  0.372833  0.580822      3119   
641         10371         14773         26916  0.385310  0.548856      4402   
642          3938          6170         10824  0.363821  0.570030      2232   
643           719          2069          2921  0.246149  0.708319      1350   
644          6293         10049         17239  0.365044  0.582922      3756   
645          1920          3437          5717  0.335840  0.601189      1517   
646          5238          5332         11217  0.466970  0.475350        94   
647         16102         24627         42933  0.375049  0.573615      8525   
648          1523          2443          4216  0.361243  0.579459       920   
649          1890          3790          5949  0.317700  0.637082      1900   

     per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
551          -0.353551    IA  19001          3959    ...         13.5   
552          -0.397695    IA  19003          2158    ...          9.5   
553          -0.243235    IA  19005          6824    ...         22.4   
554          -0.363845    IA  19007          6176    ...         25.9   
555          -0.312518    IA  19009          3439    ...         13.8   
556          -0.259606    IA  19011         13959    ...         36.4   
557           0.073140    IA  19013         66205    ...        231.7   
558          -0.138801    IA  19015         14237    ...         46.0   
559          -0.138577    IA  19017         13218    ...         55.7   
560          -0.151721    IA  19019         10478    ...         36.7   
561          -0.249908    IA  19021          8322    ...         35.2   
562          -0.369452    IA  19023          7510    ...         25.6   
563          -0.405485    IA  19025          5190    ...         17.0   
564          -0.318352    IA  19027         10581    ...         36.6   
565          -0.398157    IA  19029          7167    ...         24.7   
566          -0.180801    IA  19031          9548    ...         31.9   
567          -0.077011    IA  19033         23548    ...         77.7   
568          -0.406078    IA  19035          6367    ...         20.9   
569          -0.231663    IA  19037          6462    ...         24.7   
570          -0.282179    IA  19039          4398    ...         21.5   
571          -0.424257    IA  19041          8400    ...         29.4   
572          -0.227852    IA  19043          9035    ...         23.3   
573          -0.051433    IA  19045         24873    ...         70.7   
574          -0.382250    IA  19047          6686    ...         23.9   
575          -0.096393    IA  19049         37799    ...        112.4   
576          -0.452307    IA  19051          3738    ...         17.4   
577          -0.295706    IA  19053          3812    ...         15.9   
578          -0.298091    IA  19055          9323    ...         30.7   
579          -0.069524    IA  19057         20264    ...         96.9   
580          -0.360301    IA  19059         10118    ...         43.8   
..                 ...   ...    ...           ...    ...          ...   
620          -0.066279    IA  19139         19726    ...         97.7   
621          -0.601660    IA  19141          7295    ...         25.1   
622          -0.618079    IA  19143          3179    ...         16.2   
623          -0.441160    IA  19145          7014    ...         29.8   
624          -0.360291    IA  19147          4857    ...         16.7   
625          -0.519338    IA  19149         12909    ...         29.0   
626          -0.451579    IA  19151          3992    ...         12.7   
627           0.114920    IA  19153        227563    ...        750.5   
628          -0.215507    IA  19155         41679    ...         98.0   
629          -0.068503    IA  19157          9858    ...         32.3   
630          -0.397541    IA  19159          2578    ...          9.6   
631          -0.469756    IA  19161          5256    ...         18.0   
632           0.014362    IA  19163         89826    ...        360.7   
633          -0.429187    IA  19165          6456    ...         20.6   
634          -0.693313    IA  19167         17181    ...         43.9   
635           0.122143    IA  19169         46529    ...        156.3   
636          -0.205419    IA  19171          8930    ...         24.6   
637          -0.450549    IA  19173          2978    ...         11.9   
638          -0.277566    IA  19175          5899    ...         29.6   
639          -0.476744    IA  19177          3540    ...         15.6   
640          -0.207989    IA  19179         15630    ...         82.5   
641          -0.163546    IA  19181         25875    ...         81.1   
642          -0.206208    IA  19183         10880    ...         38.2   
643          -0.462170    IA  19185          2886    ...         12.2   
644          -0.217878    IA  19187         18118    ...         53.1   
645          -0.265349    IA  19189          5878    ...         27.1   
646          -0.008380    IA  19191         11016    ...         30.5   
647          -0.198565    IA  19193         44702    ...        117.1   
648          -0.218216    IA  19195          4143    ...         19.0   
649          -0.319381    IA  19197          6174    ...         22.8   

     Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
551      -0.151815      0.120402    0.749378      0.196284   0.096013   
552      -0.200359      0.157947    0.762705      0.183313   0.093637   
553      -0.162160      0.122253    0.733559      0.212693   0.137976   
554      -0.177657      0.150729    0.718338      0.228122   0.057085   
555      -0.148253      0.108436    0.751097      0.195473   0.119253   
556      -0.149452      0.104064    0.729163      0.214403   0.128287   
557      -0.087929      0.039218    0.586857      0.356978   0.153742   
558      -0.129254      0.073957    0.701202      0.240524   0.167878   
559      -0.106967      0.056349    0.648935      0.289050   0.109684   
560      -0.172131      0.118930    0.741277      0.204217   0.198316   
561      -0.093986      0.051981    0.644557      0.310598   0.046073   
562      -0.152147      0.113043    0.758332      0.187263   0.098818   
563      -0.156600      0.122102    0.701952      0.241637   0.023010   
564      -0.147506      0.107997    0.721871      0.221805   0.086796   
565      -0.122660      0.086296    0.705227      0.234224   0.031237   
566      -0.135237      0.089657    0.721399      0.221399   0.159392   
567      -0.125964      0.083543    0.671409      0.267455   0.159635   
568      -0.141034      0.102802    0.709095      0.233306   0.032083   
569      -0.194092      0.148373    0.772310      0.177173   0.185063   
570      -0.165149      0.131355    0.722257      0.223893   0.107955   
571      -0.137421      0.099812    0.715332      0.224941   0.028139   
572      -0.172043      0.124653    0.735026      0.207489   0.151491   
573      -0.164937      0.115660    0.698021      0.246619   0.203516   
574      -0.164659      0.135479    0.692599      0.262777   0.021075   
575      -0.019266     -0.040733    0.502200      0.428464  -0.010547   
576      -0.153119      0.134662    0.725242      0.223555   0.019954   
577      -0.145238      0.109807    0.701902      0.248339   0.081864   
578      -0.171408      0.124215    0.761295      0.184959   0.140673   
579      -0.148894      0.105342    0.666368      0.277141   0.159822   
580      -0.106287      0.073840    0.674368      0.264733   0.016322   
..             ...           ...         ...           ...        ...   
620      -0.134402      0.087053    0.693291      0.255707   0.192977   
621      -0.090401      0.059580    0.705949      0.236203  -0.074535   
622      -0.113277      0.090836    0.762313      0.190286  -0.028428   
623      -0.110509      0.081150    0.706538      0.238946   0.006911   
624      -0.138847      0.113352    0.746215      0.200805   0.087465   
625      -0.100908      0.075336    0.707990      0.233644  -0.031766   
626      -0.129151      0.104492    0.696318      0.241950  -0.006371   
627      -0.039734     -0.013001    0.516128      0.420806   0.107140   
628      -0.100884      0.056944    0.685219      0.257888   0.106405   
629      -0.097614      0.061983    0.647975      0.289316   0.138741   
630      -0.177556      0.148224    0.733548      0.213702   0.055455   
631      -0.156752      0.128643    0.725082      0.218432   0.009300   
632      -0.088277      0.034938    0.539645      0.397575   0.079184   
633      -0.119282      0.087631    0.724353      0.219353   0.032168   
634      -0.028916     -0.015308    0.680011      0.265370  -0.140546   
635      -0.044621     -0.029580    0.392457      0.527297   0.001719   
636      -0.160612      0.118827    0.686915      0.253842   0.111648   
637      -0.172023      0.137828    0.730834      0.211724   0.028869   
638      -0.180606      0.135780    0.705582      0.234423   0.095146   
639      -0.155834      0.134469    0.751256      0.197574   0.035431   
640      -0.178415      0.147232    0.694517      0.254440   0.113696   
641      -0.098594      0.045242    0.650757      0.284225   0.101902   
642      -0.103183      0.060838    0.702342      0.242730   0.132313   
643      -0.187323      0.159809    0.761914      0.187124   0.053595   
644      -0.156978      0.116370    0.674115      0.271238   0.091192   
645      -0.156674      0.108335    0.700604      0.240369   0.099414   
646      -0.099933      0.056141    0.655691      0.281703   0.180341   
647      -0.117680      0.078424    0.636528      0.308643   0.062914   
648      -0.204289      0.158750    0.723809      0.217028   0.144350   
649      -0.134842      0.101125    0.723157      0.222116   0.086075   

    Clinton_Dev  winner16  winner12     change  
551   -0.103530       GOP       GOP        GOP  
552   -0.088060       GOP       GOP        GOP  
553   -0.139655       GOP       Dem  GOPchange  
554   -0.069286       GOP       GOP        GOP  
555   -0.123852       GOP       GOP        GOP  
556   -0.126868       GOP       GOP        GOP  
557   -0.149278       Dem       Dem        Dem  
558   -0.153999       GOP       Dem  GOPchange  
559   -0.111624       GOP       Dem  GOPchange  
560   -0.187023       GOP       Dem  GOPchange  
561   -0.037977       GOP       GOP        GOP  
562   -0.102800       GOP       GOP        GOP  
563   -0.031820       GOP       GOP        GOP  
564   -0.094918       GOP       GOP        GOP  
565   -0.041609       GOP       GOP        GOP  
566   -0.159807       GOP       Dem  GOPchange  
567   -0.167309       GOP       Dem  GOPchange  
568   -0.037628       GOP       GOP        GOP  
569   -0.178410       GOP       Dem  GOPchange  
570   -0.108230       GOP       Dem  GOPchange  
571   -0.037995       GOP       GOP        GOP  
572   -0.148194       GOP       Dem  GOPchange  
573   -0.196453       GOP       Dem  GOPchange  
574   -0.026498       GOP       GOP        GOP  
575    0.012109       GOP       GOP        GOP  
576   -0.029426       GOP       GOP        GOP  
577   -0.075993       GOP       GOP        GOP  
578   -0.137572       GOP       GOP        GOP  
579   -0.159881       GOP       Dem  GOPchange  
580   -0.033013       GOP       GOP        GOP  
..          ...       ...       ...        ...  
620   -0.178328       GOP       Dem  GOPchange  
621    0.057379       GOP       GOP        GOP  
622    0.017624       GOP       GOP        GOP  
623   -0.019522       GOP       GOP        GOP  
624   -0.097655       GOP       GOP        GOP  
625    0.013226       GOP       GOP        GOP  
626   -0.009159       GOP       GOP        GOP  
627   -0.103102       Dem       Dem        Dem  
628   -0.105419       GOP       GOP        GOP  
629   -0.151414       GOP       Dem  GOPchange  
630   -0.066849       GOP       GOP        GOP  
631   -0.027594       GOP       GOP        GOP  
632   -0.077248       Dem       Dem        Dem  
633   -0.043645       GOP       GOP        GOP  
634    0.138125       GOP       GOP        GOP  
635    0.014416       Dem       Dem        Dem  
636   -0.116005       GOP       Dem  GOPchange  
637   -0.039692       GOP       GOP        GOP  
638   -0.098448       GOP       Dem  GOPchange  
639   -0.041507       GOP       GOP        GOP  
640   -0.118393       GOP       Dem  GOPchange  
641   -0.101085       GOP       GOP        GOP  
642   -0.121091       GOP       GOP        GOP  
643   -0.059025       GOP       GOP        GOP  
644   -0.093807       GOP       Dem  GOPchange  
645   -0.095472       GOP       GOP        GOP  
646   -0.185266       GOP       Dem  GOPchange  
647   -0.066406       GOP       GOP        GOP  
648   -0.144215       GOP       Dem  GOPchange  
649   -0.095585       GOP       GOP        GOP  

[99 rows x 77 columns]
      votes_dem_16  votes_gop_16  tot_votes_16   Clinton     Trump  diff_216  \
2806          6737          8582         15755  0.427610  0.544716      1845   
2807         33297         19232         56134  0.593170  0.342609     14065   
2808         57147         13241         74384  0.768270  0.178009     43906   
2809          2165          4873          7306  0.296332  0.666986      2708   
2810          2150          4704          7035  0.305615  0.668657      2554   
2811          4986          9643         15164  0.328805  0.635914      4657   
2812          2023          5714          7954  0.254337  0.718381      3691   
2813         91879         20155        119344  0.769867  0.168882     71724   
2814          8108         26152         36661  0.221161  0.713347     18044   
2815           603          1548          2243  0.268836  0.690147       945   
2816          9733         30578         42186  0.230716  0.724838     20845   
2817           453          2572          3124  0.145006  0.823303      2119   
2818          4492         13369         18641  0.240974  0.717183      8877   
2819          1832          4884          6966  0.262992  0.701120      3052   
2820          4473          3045          7645  0.585088  0.398300      1428   
2821          1721          7292          9220  0.186659  0.790889      5571   
2822          3128          3969          7284  0.429434  0.544893       841   
2823           693          1432          2395  0.289353  0.597912       739   
2824          6597         19442         27218  0.242376  0.714307     12845   
2825          6425          7143         14189  0.452816  0.503418       718   
2826          2557         10653         13587  0.188195  0.784058      8096   
2827          2244          1381          3745  0.599199  0.368758       863   
2828          2153          3479          5792  0.371720  0.600656      1326   
2829         17865          2951         22211  0.804331  0.132862     14914   
2830         52554         53988        111827  0.469958  0.482781      1434   
2831         80993         84938        175288  0.462057  0.484563      3945   
2832          3047          4657          8131  0.374739  0.572746      1610   
2833          2367          5681          8427  0.280883  0.674143      3314   
2834           914          1349          2369  0.385817  0.569439       435   
2835           541          2139          2784  0.194325  0.768319      1598   
...            ...           ...           ...       ...       ...       ...   
2909          1741          2532          4444  0.391764  0.569757       791   
2910          1347          2213          3651  0.368940  0.606135       866   
2911         74640         14254         94724  0.787973  0.150479     60386   
2912         16787         30857         50149  0.334742  0.615306     14070   
2913         23403         16045         41728  0.560846  0.384514      7358   
2914          3506          6671         10685  0.328124  0.624333      3165   
2915          9361         25269         36536  0.256213  0.691619     15908   
2916          2328          9516         12195  0.190898  0.780320      7188   
2917          4212          7225         12129  0.347267  0.595680      3013   
2918          1579          8242         10055  0.157036  0.819692      6663   
2919          5269         14078         20335  0.259110  0.692304      8809   
2920          2661          9747         12825  0.207485  0.760000      7086   
2921          3595          5035          8872  0.405207  0.567516      1440   
2922         24204         34619         62083  0.389865  0.557624     10415   
2923         27879         33840         65350  0.426611  0.517827      5961   
2924          5329          5129         11144  0.478195  0.460248       200   
2925         23012         17206         41929  0.548833  0.410360      5806   
2926          2069          1785          3976  0.520372  0.448944       284   
2927          2874          2055          5036  0.570691  0.408062       819   
2928          2895         15160         18495  0.156529  0.819681     12265   
2929         76744         84389        171876  0.446508  0.490988      7645   
2930          5165         11762         17791  0.290315  0.661121      6597   
2931          5548         19309         25715  0.215750  0.750885     13761   
2932          3762          4798          9114  0.412772  0.526443      1036   
2933          3723          4331          8291  0.449041  0.522374       608   
2934          5199          1921          7534  0.690072  0.254977      3278   
2935          5161          4786         10574  0.488084  0.452620       375   
2936          2687         11983         14991  0.179241  0.799346      9296   
2937          2765         10044         13250  0.208679  0.758038      7279   
2938         12989         18823         34062  0.381334  0.552610      5834   

      per_point_diff_16 State   FIPS  tot_votes_12    ...      Density  \
2806          -0.117106    VA  51001         16020    ...         73.8   
2807           0.250561    VA  51003         53732    ...        137.3   
2808           0.590261    VA  51510         73470    ...       9314.3   
2809          -0.370654    VA  51005          7162    ...         36.5   
2810          -0.363042    VA  51007          6885    ...         35.7   
2811          -0.307109    VA  51009         14937    ...         68.3   
2812          -0.464043    VA  51011          7924    ...         44.9   
2813           0.600985    VA  51013        117279    ...       7993.6   
2814          -0.492185    VA  51015         33614    ...         76.3   
2815          -0.421311    VA  51017          2218    ...          8.9   
2816          -0.494121    VA  51019         40750    ...         91.2   
2817          -0.678297    VA  51021          2937    ...         19.1   
2818          -0.476208    VA  51023         18208    ...         61.2   
2819          -0.438128    VA  51520          7356    ...       1370.6   
2820           0.186789    VA  51025          8029    ...         30.8   
2821          -0.604230    VA  51027          9636    ...         47.9   
2822          -0.115459    VA  51029          7447    ...         29.6   
2823          -0.308559    VA  51530          2526    ...        991.9   
2824          -0.471930    VA  51031         25632    ...        108.8   
2825          -0.050603    VA  51033         13590    ...         54.1   
2826          -0.595864    VA  51035         12315    ...         63.3   
2827           0.230441    VA  51036          4213    ...         39.7   
2828          -0.228936    VA  51037          5897    ...         26.5   
2829           0.671469    VA  51540         21455    ...       4246.4   
2830          -0.012823    VA  51550        110105    ...        652.0   
2831          -0.022506    VA  51041        172223    ...        747.1   
2832          -0.198008    VA  51043          7731    ...         79.7   
2833          -0.393260    VA  51570          8593    ...       2315.3   
2834          -0.183622    VA  51580          2329    ...       1090.2   
2835          -0.573994    VA  51045          2664    ...         15.7   
...                 ...   ...    ...           ...    ...          ...   
2909          -0.177993    VA  51157          4331    ...         27.7   
2910          -0.237195    VA  51159          3768    ...         48.3   
2911           0.637494    VA  51760         92175    ...       3414.7   
2912          -0.280564    VA  51161         53793    ...        368.7   
2913           0.176332    VA  51770         37479    ...       2279.8   
2914          -0.296210    VA  51163         10155    ...         37.3   
2915          -0.435406    VA  51165         34783    ...         89.9   
2916          -0.589422    VA  51167         12063    ...         61.0   
2917          -0.248413    VA  51775         12270    ...       1717.9   
2918          -0.662655    VA  51169          9964    ...         43.3   
2919          -0.433194    VA  51171         19289    ...         82.5   
2920          -0.552515    VA  51173         12751    ...         71.4   
2921          -0.162308    VA  51175          9261    ...         31.0   
2922          -0.167759    VA  51177         57797    ...        304.9   
2923          -0.091217    VA  51179         60338    ...        479.5   
2924           0.017947    VA  51790         11154    ...       1188.8   
2925           0.138472    VA  51800         42381    ...        211.4   
2926           0.071429    VA  51181          4302    ...         25.3   
2927           0.162629    VA  51183          5421    ...         24.7   
2928          -0.663152    VA  51185         17712    ...         86.9   
2929          -0.044480    VA  51810        195823    ...       1758.9   
2930          -0.370805    VA  51187         16636    ...        176.0   
2931          -0.535135    VA  51191         25582    ...         97.8   
2932          -0.113671    VA  51820          8772    ...       1396.8   
2933          -0.073333    VA  51193          8689    ...         76.1   
2934           0.435094    VA  51830          7722    ...       1559.3   
2935           0.035464    VA  51840         10254    ...       2838.0   
2936          -0.620105    VA  51195         14937    ...        102.8   
2937          -0.549358    VA  51197         12336    ...         63.3   
2938          -0.171276    VA  51199         33848    ...        624.8   

      Clinton_Obama  Trump_Romney  Trump_Pred  Clinton_Pred  Trump_Dev  \
2806      -0.050105      0.032107    0.581350      0.393294   0.036634   
2807       0.040203     -0.090336    0.386286      0.549346   0.043677   
2808       0.054591     -0.097001    0.157486      0.785520  -0.020523   
2809      -0.178815      0.165031    0.749784      0.211480   0.082798   
2810      -0.055751      0.040625    0.706145      0.273623   0.037488   
2811      -0.066053      0.042421    0.682317      0.293122   0.046403   
2812      -0.055228      0.044479    0.659381      0.308273  -0.059000   
2813       0.077688     -0.124717    0.141770      0.785838  -0.027112   
2814      -0.059912      0.010842    0.730029      0.228557   0.016682   
2815      -0.134229      0.115756    0.667812      0.276449  -0.022335   
2816      -0.037382      0.006285    0.663496      0.289370  -0.061342   
2817      -0.105249      0.093307    0.753350      0.204727  -0.069954   
2818      -0.058290      0.032264    0.676580      0.270205  -0.040602   
2819      -0.075100      0.051854    0.676170      0.282652  -0.024950   
2820      -0.036782      0.029013    0.519995      0.483981   0.121696   
2821      -0.134428      0.122977    0.843232      0.139813   0.052343   
2822      -0.073721      0.065640    0.635336      0.359014   0.090443   
2823      -0.074463     -0.021248    0.736164      0.231784   0.138252   
2824      -0.053777      0.024271    0.671466      0.290901  -0.042841   
2825      -0.081254      0.051027    0.612454      0.362650   0.109036   
2826      -0.096012      0.105942    0.804408      0.164642   0.020349   
2827      -0.058765      0.037403    0.547837      0.447625   0.179079   
2828      -0.052564      0.039184    0.638043      0.347857   0.037387   
2829       0.046140     -0.090909    0.259289      0.680428   0.126426   
2830      -0.029556     -0.006252    0.463915      0.492765  -0.018866   
2831       0.003616     -0.044832    0.448405      0.503092  -0.036157   
2832      -0.043965      0.017191    0.614370      0.332690   0.041623   
2833      -0.014823     -0.016769    0.613540      0.340927  -0.060603   
2834      -0.180521      0.150804    0.734435      0.235702   0.164997   
2835      -0.117237      0.108784    0.774061      0.174607   0.005742   
...             ...           ...         ...           ...        ...   
2909      -0.063327      0.037086    0.628915      0.327289   0.059158   
2910      -0.048788      0.032887    0.671968      0.318451   0.065833   
2911       0.017298     -0.063592    0.272018      0.702187   0.121539   
2912      -0.029413     -0.004551    0.587425      0.356488  -0.027881   
2913      -0.030925      0.007876    0.487708      0.479364   0.103194   
2914      -0.074338      0.043536    0.698937      0.255863   0.074604   
2915      -0.032980     -0.003347    0.715146      0.245960   0.023527   
2916      -0.117151      0.102462    0.830136      0.142561   0.049816   
2917      -0.040345      0.001629    0.578206      0.369104  -0.017474   
2918      -0.083329      0.073104    0.830751      0.141809   0.011059   
2919      -0.075900      0.042918    0.712110      0.241659   0.019806   
2920      -0.119469      0.103110    0.762240      0.200156   0.002240   
2921      -0.073899      0.056448    0.612821      0.372762   0.045306   
2922      -0.045279      0.007111    0.549904      0.400905  -0.007721   
2923      -0.023023     -0.019629    0.458656      0.484441  -0.059172   
2924      -0.033729     -0.011063    0.572392      0.382467   0.112144   
2925      -0.022036     -0.009120    0.438464      0.530899   0.028104   
2926      -0.077954      0.060520    0.567426      0.424120   0.118482   
2927      -0.047276      0.035253    0.564405      0.448601   0.156343   
2928      -0.050167      0.038120    0.789557      0.179802  -0.030124   
2929      -0.034350     -0.015117    0.445965      0.496915  -0.045023   
2930      -0.097338      0.068130    0.710940      0.247441   0.049819   
2931      -0.060851      0.041753    0.725633      0.231865  -0.025252   
2932      -0.024529     -0.019499    0.620972      0.335431   0.094529   
2933      -0.029150      0.048671    0.635715      0.342302   0.113341   
2934       0.055392     -0.091824    0.313037      0.619897   0.058059   
2935      -0.008210     -0.029436    0.502574      0.447526   0.049954   
2936      -0.071880      0.060175    0.782806      0.193288  -0.016541   
2937      -0.097903      0.083265    0.769371      0.192360   0.011333   
2938      -0.007611     -0.043644    0.436329      0.499767  -0.116281   

     Clinton_Dev  winner16  winner12     change  
2806   -0.034316       GOP       GOP        GOP  
2807   -0.043823       Dem       Dem        Dem  
2808    0.017250       Dem       Dem        Dem  
2809   -0.084851       GOP       GOP        GOP  
2810   -0.031991       GOP       GOP        GOP  
2811   -0.035683       GOP       GOP        GOP  
2812    0.053935       GOP       GOP        GOP  
2813    0.015971       Dem       Dem        Dem  
2814    0.007395       GOP       GOP        GOP  
2815    0.007613       GOP       GOP        GOP  
2816    0.058653       GOP       GOP        GOP  
2817    0.059720       GOP       GOP        GOP  
2818    0.029231       GOP       GOP        GOP  
2819    0.019660       GOP       GOP        GOP  
2820   -0.101107       Dem       Dem        Dem  
2821   -0.046846       GOP       GOP        GOP  
2822   -0.070421       GOP       Dem  GOPchange  
2823   -0.057569       GOP       GOP        GOP  
2824    0.048525       GOP       GOP        GOP  
2825   -0.090166       GOP       Dem  GOPchange  
2826   -0.023553       GOP       GOP        GOP  
2827   -0.151574       Dem       Dem        Dem  
2828   -0.023862       GOP       GOP        GOP  
2829   -0.123904       Dem       Dem        Dem  
2830    0.022807       GOP       Dem  GOPchange  
2831    0.041035       GOP       GOP        GOP  
2832   -0.042049       GOP       GOP        GOP  
2833    0.060044       GOP       GOP        GOP  
2834   -0.150115       GOP       Dem  GOPchange  
2835   -0.019717       GOP       GOP        GOP  
...          ...       ...       ...        ...  
2909   -0.064476       GOP       GOP        GOP  
2910   -0.050489       GOP       GOP        GOP  
2911   -0.085787       Dem       Dem        Dem  
2912    0.021745       GOP       GOP        GOP  
2913   -0.081483       Dem       Dem        Dem  
2914   -0.072260       GOP       GOP        GOP  
2915   -0.010253       GOP       GOP        GOP  
2916   -0.048337       GOP       GOP        GOP  
2917    0.021838       GOP       GOP        GOP  
2918   -0.015227       GOP       GOP        GOP  
2919   -0.017451       GOP       GOP        GOP  
2920   -0.007329       GOP       GOP        GOP  
2921   -0.032446       GOP       GOP        GOP  
2922    0.011040       GOP       GOP        GOP  
2923    0.057831       GOP       GOP        GOP  
2924   -0.095727       Dem       Dem        Dem  
2925   -0.017934       Dem       Dem        Dem  
2926   -0.096252       Dem       Dem        Dem  
2927   -0.122090       Dem       Dem        Dem  
2928    0.023273       GOP       GOP        GOP  
2929    0.050407       GOP       GOP        GOP  
2930   -0.042874       GOP       GOP        GOP  
2931    0.016116       GOP       GOP        GOP  
2932   -0.077341       GOP       GOP        GOP  
2933   -0.106739       GOP       Dem  GOPchange  
2934   -0.070175       Dem       Dem        Dem  
2935   -0.040558       Dem       Dem        Dem  
2936    0.014047       GOP       GOP        GOP  
2937   -0.016319       GOP       GOP        GOP  
2938    0.118433       GOP       GOP        GOP  

[133 rows x 77 columns]

In [364]:
FL = raw[raw.State == 'FL'] 
CO = raw[raw.State == 'CO']
PA = raw[raw.State == 'PA']
NH = raw[raw.State == 'NH']
NV = raw[raw.State == 'NV'] 
OH = raw[raw.State == 'OH']
WI = raw[raw.State == 'WI'] 
MI = raw[raw.State == 'MI']
IA = raw[raw.State == 'IA']
NC = raw[raw.State == 'NC']
VA = raw[raw.State == 'VA']

I used the below code to double check that all the states had been included in the final total data frame.


In [365]:
dfs = [FL, PA, OH, CO, IA, MI, NV, NH, NC, VA, WI]
finalfull = pd.concat(dfs, keys=swingstate)
print(list(finalfull['State']))


['FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NV', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI']

Creating the dataframes

I created 4 different data frames to be able to conduct different analyses but only was able to code the graphs for the first data frame which was the general elction and looking at which counties changed. It's key to change the index to integers otherwise a key part of graphing the data will not work. However, the multiple methods of trial and error didn't result in me being able to set the index with FIPS as an int.


In [372]:
elect= [ 'FIPS',"County" , "State", 'Clinton',
             'Trump',  'Obama', 'Romney', "winner16", "winner12", "change"]
election = finalfull[elect]
#raw.loc[:, election[FIPS"]] = election["FIPS"].astype(int)

In [369]:
s = pd.Series(election["FIPS"])
a = pd.to_numeric(s)
b = pd.Series(election["FIPS"])
c = pd.to_numeric(s)

In [373]:
g = election["FIPS"].astype(int)
print(g)


FL  321     12001
    322     12003
    323     12005
    324     12007
    325     12009
    326     12011
    327     12013
    328     12015
    329     12017
    330     12019
    331     12021
    332     12023
    333     12027
    334     12029
    335     12031
    336     12033
    337     12035
    338     12037
    339     12039
    340     12041
    341     12043
    342     12045
    343     12047
    344     12049
    345     12051
    346     12053
    347     12055
    348     12057
    349     12059
    350     12061
            ...  
VA  3034    55083
    3035    55085
    3036    55087
    3037    55089
    3038    55091
    3039    55093
    3040    55095
    3041    55097
    3042    55099
    3043    55101
    3044    55103
    3045    55105
    3046    55107
    3047    55111
    3048    55113
    3049    55115
    3050    55117
    3051    55109
    3052    55119
    3053    55121
    3054    55123
    3055    55125
    3056    55127
    3057    55129
    3058    55131
    3059    55133
    3060    55135
    3061    55137
    3062    55139
    3063    55141
Name: FIPS, dtype: int64

In [379]:
raw.loc[:, election["FIPS"]] = "g"
#election["FIPS"] = g
#election.set_index("FIPS")
#election.head()


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-379-ed6753c27306> in <module>()
----> 1 raw.loc[:, election["FIPS"]] = "g"
      2 #election["FIPS"] = g
      3 #election.set_index("FIPS")
      4 #election.head()

/Users/Chandra/anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in __setitem__(self, key, value)
    129         else:
    130             key = com._apply_if_callable(key, self.obj)
--> 131         indexer = self._get_setitem_indexer(key)
    132         self._setitem_with_indexer(indexer, value)
    133 

/Users/Chandra/anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in _get_setitem_indexer(self, key)
    111 
    112         if isinstance(key, tuple) and not self.ndim < len(key):
--> 113             return self._convert_tuple(key, is_setter=True)
    114         if isinstance(key, range):
    115             return self._convert_range(key, is_setter=True)

/Users/Chandra/anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in _convert_tuple(self, key, is_setter)
    173         else:
    174             for i, k in enumerate(key):
--> 175                 idx = self._convert_to_indexer(k, axis=i, is_setter=is_setter)
    176                 keyidx.append(idx)
    177         return tuple(keyidx)

/Users/Chandra/anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
   1212                 mask = check == -1
   1213                 if mask.any():
-> 1214                     raise KeyError('%s not in index' % objarr[mask])
   1215 
   1216                 return _values_from_object(indexer)

KeyError: '[12001 12003 12005 12007 12009 12011 12013 12015 12017 12019 12021 12023\n 12027 12029 12031 12033 12035 12037 12039 12041 12043 12045 12047 12049\n 12051 12053 12055 12057 12059 12061 12063 12065 12067 12069 12071 12073\n 12075 12077 12079 12081 12083 12085 12086 12087 12089 12091 12093 12095\n 12097 12099 12101 12103 12105 12107 12113 12115 12117 12109 12111 12119\n 12121 12123 12125 12127 12129 12131 12133 42001 42003 42005 42007 42009\n 42011 42013 42015 42017 42019 42021 42023 42025 42027 42029 42031 42033\n 42035 42037 42039 42041 42043 42045 42047 42049 42051 42053 42055 42057\n 42059 42061 42063 42065 42067 42069 42071 42073 42075 42077 42079 42081\n 42083 42085 42087 42089 42091 42093 42095 42097 42099 42101 42103 42105\n 42107 42109 42111 42113 42115 42117 42119 42121 42123 42125 42127 42129\n 42131 42133 39001 39003 39005 39007 39009 39011 39013 39015 39017 39019\n 39021 39023 39025 39027 39029 39031 39033 39035 39037 39039 39041 39043\n 39045 39047 39049 39051 39053 39055 39057 39059 39061 39063 39065 39067\n 39069 39071 39073 39075 39077 39079 39081 39083 39085 39087 39089 39091\n 39093 39095 39097 39099 39101 39103 39105 39107 39109 39111 39113 39115\n 39117 39119 39121 39123 39125 39127 39129 39131 39133 39135 39137 39139\n 39141 39143 39145 39147 39149 39151 39153 39155 39157 39159 39161 39163\n 39165 39167 39169 39171 39173 39175  8001  8003  8005  8007  8009  8011\n  8013  8014  8015  8017  8019  8021  8023  8025  8027  8029  8031  8033\n  8035  8037  8039  8041  8043  8045  8047  8049  8051  8053  8055  8057\n  8059  8061  8063  8065  8067  8069  8071  8073  8075  8077  8079  8081\n  8083  8085  8087  8089  8091  8093  8095  8097  8099  8101  8103  8105\n  8107  8109  8111  8113  8115  8117  8119  8121  8123  8125 19001 19003\n 19005 19007 19009 19011 19013 19015 19017 19019 19021 19023 19025 19027\n 19029 19031 19033 19035 19037 19039 19041 19043 19045 19047 19049 19051\n 19053 19055 19057 19059 19061 19063 19065 19067 19069 19071 19073 19075\n 19077 19079 19081 19083 19085 19087 19089 19091 19093 19095 19097 19099\n 19101 19103 19105 19107 19109 19111 19113 19115 19117 19119 19121 19123\n 19125 19127 19129 19131 19133 19135 19137 19139 19141 19143 19145 19147\n 19149 19151 19153 19155 19157 19159 19161 19163 19165 19167 19169 19171\n 19173 19175 19177 19179 19181 19183 19185 19187 19189 19191 19193 19195\n 19197 26001 26003 26005 26007 26009 26011 26013 26015 26017 26019 26021\n 26023 26025 26027 26029 26031 26033 26035 26037 26039 26041 26043 26045\n 26047 26049 26051 26053 26055 26057 26059 26061 26063 26065 26067 26069\n 26071 26073 26075 26077 26079 26081 26083 26085 26087 26089 26091 26093\n 26095 26097 26099 26101 26103 26105 26107 26109 26111 26113 26115 26117\n 26119 26121 26123 26125 26127 26129 26131 26133 26135 26137 26139 26141\n 26143 26145 26151 26153 26155 26147 26149 26157 26159 26161 26163 26165\n 32510 32001 32003 32005 32007 32009 32011 32013 32015 32017 32019 32021\n 32023 32027 32029 32031 32033 33001 33003 33005 33007 33009 33011 33013\n 33015 33017 33019 37001 37003 37005 37007 37009 37011 37013 37015 37017\n 37019 37021 37023 37025 37027 37029 37031 37033 37035 37037 37039 37041\n 37043 37045 37047 37049 37051 37053 37055 37057 37059 37061 37063 37065\n 37067 37069 37071 37073 37075 37077 37079 37081 37083 37085 37087 37089\n 37091 37093 37095 37097 37099 37101 37103 37105 37107 37109 37113 37115\n 37117 37111 37119 37121 37123 37125 37127 37129 37131 37133 37135 37137\n 37139 37141 37143 37145 37147 37149 37151 37153 37155 37157 37159 37161\n 37163 37165 37167 37169 37171 37173 37175 37177 37179 37181 37183 37185\n 37187 37189 37191 37193 37195 37197 37199 51001 51003 51510 51005 51007\n 51009 51011 51013 51015 51017 51019 51021 51023 51520 51025 51027 51029\n 51530 51031 51033 51035 51036 51037 51540 51550 51041 51043 51570 51580\n 51045 51047 51049 51590 51051 51053 51595 51057 51059 51600 51610 51061\n 51063 51065 51067 51620 51069 51630 51640 51071 51073 51075 51077 51079\n 51081 51083 51650 51085 51660 51087 51089 51091 51670 51093 51095 51097\n 51099 51101 51103 51105 51678 51107 51109 51111 51680 51113 51683 51685\n 51690 51115 51117 51119 51121 51125 51127 51700 51710 51131 51133 51720\n 51135 51137 51139 51141 51730 51143 51735 51740 51145 51147 51149 51153\n 51155 51750 51157 51159 51760 51161 51770 51163 51165 51167 51775 51169\n 51171 51173 51175 51177 51179 51790 51800 51181 51183 51185 51810 51187\n 51191 51820 51193 51830 51840 51195 51197 51199 55001 55003 55005 55007\n 55009 55011 55013 55015 55017 55019 55021 55023 55025 55027 55029 55031\n 55033 55035 55037 55039 55041 55043 55045 55047 55049 55051 55053 55055\n 55057 55059 55061 55063 55065 55067 55069 55071 55073 55075 55077 55078\n 55079 55081 55083 55085 55087 55089 55091 55093 55095 55097 55099 55101\n 55103 55105 55107 55111 55113 55115 55117 55109 55119 55121 55123 55125\n 55127 55129 55131 55133 55135 55137 55139 55141] not in index'

In [324]:
print(type(election["FIPS"]))


<class 'pandas.core.series.Series'>

Graphing the data

Here comes the fun part. I chose to use the plotly graph because I though the visuals given so many data points were much better. The following code allows me to use a large map of the US shown by County. It would display counties the Dems held in Red, the GOP held Blue, and if it changed hands in Orange or Purple. By creating different variables to sort out the key components such as the map, the color, we can declutter the final graphing solution.


In [381]:
# this is the "scale" or view for the map
sc_geo_county = AlbersUSA()


sc_c1_county = OrdinalColorScale(domain=['GOP', 'Dem', 'GOPchange', 'Demchange'], colors=['Red', 'DeepSkyBlue','Orange' , "Purple"])
axis_county = ColorAxis(scale=sc_c1_county)

# this is the actual data that we will map. 
# It is a dict that maps FIPS to winner's name (that's why we did set_index above)
color_data_county = election2["change"].to_dict()

# build the map
county_map = Map(map_data=topo_load('map_data/USCountiesMap.json'), 
                 color=color_data_county,
                 scales=dict(projection=sc_geo_county, color=sc_c1_county),
                 colors=dict(default_color="Grey"))


# put the map in a figure 
county_fig = Figure(marks=[county_map], 
                    axes=[axis_county],
                    title='US Elections 2012-16 changes',
                    min_width=1000, min_height=600)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-381-1d0c4fb8a0a6> in <module>()
     14                  color=color_data_county,
     15                  scales=dict(projection=sc_geo_county, color=sc_c1_county),
---> 16                  colors=dict(default_color="Grey"))
     17 
     18 

/Users/Chandra/anaconda/lib/python3.5/site-packages/bqplot/marks.py in __init__(self, **kwargs)
    213 
    214     def __init__(self, **kwargs):
--> 215         super(Mark, self).__init__(**kwargs)
    216         self._hover_handlers = CallbackDispatcher()
    217         self._click_handlers = CallbackDispatcher()

/Users/Chandra/anaconda/lib/python3.5/site-packages/ipywidgets/widgets/widget.py in __init__(self, **kwargs)
    170     _holding_sync = False
    171     _states_to_send = Set()
--> 172     _display_callbacks = Instance(CallbackDispatcher, ())
    173     _msg_callbacks = Instance(CallbackDispatcher, ())
    174 

/Users/Chandra/anaconda/lib/python3.5/site-packages/traitlets/config/configurable.py in __init__(self, **kwargs)
     72         # load kwarg traits, other than config
     73         super(Configurable, self).__init__(**kwargs)
---> 74 
     75         # load config
     76         if config is not None:

/Users/Chandra/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py in __init__(self, *args, **kwargs)
    950         # the cls argument.
    951         new_meth = super(HasDescriptors, cls).__new__
--> 952         if new_meth is object.__new__:
    953             inst = new_meth(cls)
    954         else:

/Users/Chandra/anaconda/lib/python3.5/contextlib.py in __exit__(self, type, value, traceback)
     64         if type is None:
     65             try:
---> 66                 next(self.gen)
     67             except StopIteration:
     68                 return

/Users/Chandra/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py in hold_trait_notifications(self)
   1054         """
   1055         if self._cross_validation_lock:
-> 1056             yield
   1057             return
   1058         else:

/Users/Chandra/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py in _cross_validate(self, obj, value)
    570             # we explicitly compare silent to True just in case the equality
    571             # comparison above returns something other than True/False
--> 572             obj._notify_trait(self.name, old_value, new_value)
    573 
    574     def __set__(self, obj, value):

/Users/Chandra/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py in __call__(self, *args, **kwargs)
    857     ----------
    858     name
--> 859         The str name of the Trait on the object whose default should be generated.
    860 
    861     Notes

/Users/Chandra/anaconda/lib/python3.5/site-packages/bqplot/marks.py in _validate_scales(self, proposal)
    197         # At this stage it is already validated that all values in self.scales
    198         # are instances of Scale.
--> 199         scales = proposal.value
    200         for name in self.trait_names(scaled=True):
    201             trait = self.traits()[name]

AttributeError: 'dict' object has no attribute 'value'

I beileve the reason I'm getting the above error message is due to complication above. I've attempted to set the index to FIPS which needs to be an int. However,there is an error message popping that I can't resolve. As a result, when I refer to the dictionary that has the key as the value from the hange column in the election2 dataframe there is no correspondinfg FIPS value that allows the map to be charted. As a result the dict has no value, because it isn't being set as an integer.

Had this worked, I would've screenshotted different parts of the country to show the map in greater detail.


In [ ]:

Future

In the future I'd like to look at correlations between the below indicators and the counties that changed from 2016 to 2012


In [348]:
demo = ['FIPS','County', 'State', 'pop2014est', 'pop2010est', 'pop_change%', '-18', '65+', 'female', 'White', 'Black', 'Native', 'Asian', 'Pacific', 'Multi', 'Hispanic', 'White-nh', 'foreignborn', 'NonEnglish', 'highschool', 'bachelors', 'Veterans']
econ = ['FIPS', "County" ,  "State",'pop_change%', 'Homeownrate',  'tot_households', 'persperhouse', 'Percap_Inc', 'Med_house_inc', 'Poverty']
bus = ['FIPS', "County" ,  "State",'TOT_firms', 'Black_own_firms', 'Nat_own_firms', 'Asian_own_firms', 'Pac_own_firms', 'Hisp_own_firms', 'Wom_own_firms' , 'tot_ret_sales', 'Retsalepercap', 'Accomandfoodsales']
demographics = finalfull[demo]
econindicators = finalfull[econ]
bus_wellbeing = finalfull[bus]
demographics.set_index(['FIPS'])
econindicators.set_index(['FIPS'])
bus_wellbeing.set_index(['FIPS'])


Out[348]:
County State TOT_firms Black_own_firms Nat_own_firms Asian_own_firms Pac_own_firms Hisp_own_firms Wom_own_firms tot_ret_sales Retsalepercap Accomandfoodsales
FIPS
12001 Alachua County FL 20676 7.8 0.0 3.8 0.0 6.7 31.6 3152244 13124 493980
12003 Baker County FL 1727 0.0 0.0 0.0 0.0 0.0 26.2 180555 7052 19819
12005 Bay County FL 15465 0.0 0.0 0.0 0.3 2.7 29.0 2471968 15138 480359
12007 Bradford County FL 2106 0.0 0.0 0.0 0.0 0.0 0.0 215629 7436 37088
12009 Brevard County FL 45939 6.1 0.4 2.9 0.0 5.3 30.4 6593988 12339 855503
12011 Broward County FL 237524 16.4 0.5 3.7 0.1 22.1 29.8 30886257 17680 4209090
12013 Calhoun County FL 1034 0.0 0.0 0.0 0.0 0.0 0.0 64750 4791 9289
12015 Charlotte County FL 13987 0.0 0.0 0.0 0.0 0.0 26.4 1898114 12072 178021
12017 Citrus County FL 12451 2.5 0.0 0.0 0.0 0.0 30.9 1405565 10051 109681
12019 Clay County FL 15242 6.3 0.0 4.2 0.0 4.5 28.8 2005718 10997 213775
12021 Collier County FL 38309 3.3 0.0 1.8 0.0 15.5 26.8 5186468 16546 1037152
12023 Columbia County FL 5089 5.7 0.0 0.0 0.0 3.4 24.7 862158 12692 103321
12027 DeSoto County FL 1899 0.0 0.0 0.0 0.0 0.0 24.0 280786 8001 24311
12029 Dixie County FL 919 0.0 0.0 0.0 0.0 0.0 0.0 49120 3303 7395
12031 Duval County FL 69495 14.1 0.3 4.9 0.0 6.3 29.8 13316700 15688 1719352
12033 Escambia County FL 24187 9.5 0.0 3.7 0.1 2.4 30.6 4055667 13404 493882
12035 Flagler County FL 9695 0.0 0.0 0.0 0.0 0.0 0.0 684121 7766 114760
12037 Franklin County FL 1758 0.0 0.0 0.0 0.0 0.0 0.0 92324 8191 37568
12039 Gadsden County FL 2765 35.1 0.0 0.0 0.0 0.0 29.8 440290 9422 18920
12041 Gilchrist County FL 1104 0.0 0.0 0.0 0.0 0.0 0.0 52477 3102 8145
12043 Glades County FL 354 0.0 0.0 0.0 0.0 0.0 29.4 13064 1191 4894
12045 Gulf County FL 1232 0.0 0.0 0.0 0.0 0.0 0.0 76286 4840 18763
12047 Hamilton County FL 816 0.0 0.0 0.0 0.0 0.0 35.5 103218 7243 7863
12049 Hardee County FL 1363 0.0 0.0 0.0 0.0 22.0 0.0 400142 13878 17883
12051 Hendry County FL 2489 0.0 0.0 0.0 0.0 34.3 0.0 345685 8774 37321
12053 Hernando County FL 13476 3.6 0.8 0.0 0.0 8.7 26.6 1654088 9789 166197
12055 Highlands County FL 7360 0.0 0.0 3.7 0.0 14.4 24.1 1089559 11060 100789
12057 Hillsborough County FL 114841 8.6 0.6 4.5 0.0 19.9 28.6 19110290 16335 2619799
12059 Holmes County FL 937 0.0 0.0 0.0 0.0 0.0 20.3 73133 3825 8328
12061 Indian River County FL 15401 4.9 0.0 0.0 0.0 6.0 0.0 1851697 13940 190526
... ... ... ... ... ... ... ... ... ... ... ... ...
55083 Oconto County WI 3165 0.0 3.0 0.0 0.0 0.0 0.0 257543 6897 28196
55085 Oneida County WI 4167 0.0 0.0 0.0 0.0 0.0 18.2 921151 25450 84113
55087 Outagamie County WI 12666 0.3 0.0 2.1 0.0 1.0 24.1 2902996 16710 296108
55089 Ozaukee County WI 8559 0.4 0.3 1.5 0.0 0.0 26.2 976543 11432 124890
55091 Pepin County WI 0 0.0 0.0 0.0 0.0 0.0 0.0 90048 12207 0
55093 Pierce County WI 3519 0.0 0.0 1.7 0.0 0.0 28.9 208532 5243 32888
55095 Polk County WI 4606 0.0 0.0 1.0 0.0 0.0 27.3 423199 9580 41813
55097 Portage County WI 5022 2.0 0.0 0.0 0.0 0.0 25.8 937882 13685 97014
55099 Price County WI 2077 0.0 0.0 0.0 0.0 0.0 22.6 121071 8362 0
55101 Racine County WI 13283 3.8 0.0 2.2 0.0 2.1 26.2 2230013 11172 242667
55103 Richland County WI 1275 0.0 0.0 0.0 0.0 0.0 0.0 223315 12285 0
55105 Rock County WI 11212 2.7 0.4 1.6 0.0 1.9 27.9 2439767 15301 211671
55107 Rusk County WI 1562 0.0 0.0 0.0 0.0 0.0 0.0 198374 13756 0
55111 Sauk County WI 5637 0.0 0.0 0.0 0.0 0.0 23.8 1050852 18017 462144
55113 Sawyer County WI 2363 0.0 0.0 0.0 0.0 0.0 0.0 224148 13223 74686
55115 Shawano County WI 3402 0.0 0.0 0.0 0.0 2.7 23.7 413963 10068 42735
55117 Sheboygan County WI 7858 0.5 0.0 1.8 0.0 0.0 22.2 1398661 12257 193012
55109 St. Croix County WI 8287 0.0 0.0 0.6 0.0 0.3 25.4 933401 11509 110863
55119 Taylor County WI 1971 0.0 0.0 0.0 0.0 0.0 22.2 189138 9793 0
55121 Trempealeau County WI 2277 0.0 0.0 0.0 0.0 0.0 23.1 251829 9088 0
55123 Vernon County WI 2897 0.0 0.0 0.0 0.0 0.0 0.0 250463 8639 0
55125 Vilas County WI 3491 0.0 0.0 0.0 0.0 0.0 19.1 312228 14218 161614
55127 Walworth County WI 9675 0.0 0.0 1.2 0.0 1.9 25.3 1091166 10886 267234
55129 Washburn County WI 2106 0.0 0.0 0.0 0.0 0.0 17.9 178121 10746 25328
55131 Washington County WI 10318 0.6 0.3 0.0 0.0 0.4 19.9 1759993 13729 152903
55133 Waukesha County WI 36589 0.8 0.3 2.2 0.0 1.0 24.7 5955006 15712 616641
55135 Waupaca County WI 3897 0.0 0.0 0.0 0.0 0.8 24.6 516629 9929 55597
55137 Waushara County WI 2378 0.0 0.0 0.0 0.0 0.0 23.9 203004 8226 25080
55139 Winnebago County WI 10710 0.0 0.3 0.0 0.0 0.8 23.4 1796479 11126 212069
55141 Wood County WI 6203 0.0 0.0 0.0 0.0 0.0 25.3 1002909 13585 84291

800 rows × 12 columns

In the future, I'd like to look into using the filter function to only sort out the counties that changed from party to party and look at their specific economic indicators. If i was able to isolate to counties that changed hands, I could plot a scatter plot using the margin of victory by each candidate against economic indicators such as homeownership rate. Additionally, given the contraversy over immigration, I'd like to see if there's a correlation of counties that went to Trump, and are GOP territory, and the foreignborn data.


In [349]:
print(type(demographics['FIPS']))


<class 'pandas.core.series.Series'>

There was a small problem with the data regarding the population in 2010. There were 2 different numbers on that provided the estimate and one that was the actual population data. The following code is to check if there any major discrepancies. Because the numbers were few I left it with estimate so I didnt have to recreat the % of Population change. A more accurate measure would have been teh standard deviation, but I felt that was unnecessary given the small numbers.


In [274]:
popdifference = finalfull['Pop2010']-finalfull['pop2010est']

In [217]:
for num in popdifference :
    if num > 1000 or num < -1000:
        print(num)
    
for num in popdifference :
    if num > 100 or num < -100:
        print(num)


-1357
-1582
-2387
2384
-6190
-1357
-532
-1582
-270
532
-145
-260
253
-114
-129
-129
-175
-155
133
-507
-153
-275
-124
-110
-171
-2387
2384
-6190
263
-392
-199
-133
113
-263
144
395
278
-149